请教关于JAVA里new的使用,例子如下,这两个例子都能正确运行,那么new在这里该不该用呢?又有什么区别?
1.publicclassEval{publicstaticvoidmain(String[]args){Strings;s="Iloveyou";System.out....
1.
public class Eval {
public static void main(String[] args) {
String s ;
s = "I love you";
System.out.println(s);
}
}
2.
public class Eval {
public static void main(String[] args) {
String s = new String();
s = "I love you";
System.out.println(s);
}
} 展开
public class Eval {
public static void main(String[] args) {
String s ;
s = "I love you";
System.out.println(s);
}
}
2.
public class Eval {
public static void main(String[] args) {
String s = new String();
s = "I love you";
System.out.println(s);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询