我正在用java开发一个项目,其中运行主文件后,一些java文件被更改,如果我在同一次执行期间再次运行该文件,输出不会显示java文件中所做的更改
例如有2个文件。 Main.java 和 file1.java
main.java
public static void main(string[] argv)
{
file1 obj = new file1();
obj.view();
Scanner in = new Scanner(System.in);
String x = in.nextLine();
//before entering any value i manually updated the content of file1.java
obj = new file1();
obj.view();
}
file1.java(更新前)
public class file1
{
public void view()
{
system.out.println("This is test code!!");
}
}
file1.java(更新后)
public class file1
{
public void view()
{
system.out.println("That was done for Testing!!");
}
}
Output :
This is test code!!
This is test code!!
最佳答案
关于java - 在运行时重新编译对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10602832/