E:\java\实验\Data\student.java:25: illegal start of expression出错的
package LastMonth; class Student{ Student(){ System.out.println("Student object "); } } public class Sclass { /** * @param args */ static Student s ; public static void main(String[] args) { // TODO Auto-generated method stub s = new Student(); }}
不懂,你是不是想用静态方法产生对象!! public static Example getSimpton() { return new Example(); }
static不能用于声明方法内的局部变量,你应该把static Student s 放在类成员的声明中。
package LastMonth; class Student{ Student(String name){ System.out.println("Student name is: "+ name); } } public class Sclass { /** * @param args */ static Student s = new Student("louzhu");; public static void main(String[] args) { // TODO Auto-generated method stub
class Student{
Student(){
System.out.println("Student object ");
}
}
public class Sclass { /**
* @param args
*/
static Student s ;
public static void main(String[] args) {
// TODO Auto-generated method stub
s = new Student();
}}
E:\java\实验\Data\student.java:25: illegal start of expression
static student student3=new student("000","yy",9,data2);
^
1 error这样
public static Example getSimpton()
{
return new Example();
}
class Student{
Student(String name){
System.out.println("Student name is: "+ name);
}
}
public class Sclass { /**
* @param args
*/
static Student s = new Student("louzhu");;
public static void main(String[] args) {
// TODO Auto-generated method stub
}}