//Syntax error on token "void", new expected //Syntax error on tokens, AnnotationName expected instead //Syntax error, insert ";" to complete Statement
你现在改成什么样了呢? Syntax error, insert ";" to complete Statement 语句后缺少;结束
public class Practice { static String string = "static filed"; static {
String strings = "static block";
void show(){} //这是什么错误,求解 /*Multiple ers at this line - show cannot be resolved to a type - Syntax error, insert ";" to complete Statement - Syntax error on token "void", new expected - Syntax error, insert ")" to complete MethodInvocation - The method show() is undefined for the type Practice - Syntax error on token "void", delete this token - Syntax error, insert ";" to complete Statement */ //上面是错误信息,我把方法体去了也是这样 }
public class Practice { static String string = "static filed"; static {
String strings = "static block";
void show(){} //这是什么错误,求解 /*Multiple ers at this line - show cannot be resolved to a type - Syntax error, insert ";" to complete Statement - Syntax error on token "void", new expected - Syntax error, insert ")" to complete MethodInvocation - The method show() is undefined for the type Practice - Syntax error on token "void", delete this token - Syntax error, insert ";" to complete Statement */ //上面是错误信息,我把方法体去了也是这样 }
public static void main(String[] args) { }} 木有这么写的,块里面不可以写方法吧,怎么调用出来呢?
public class Practice { static String string = "static filed"; static {
String strings = "static block";
void show(){} //这是什么错误,求解 /*Multiple ers at this line - show cannot be resolved to a type - Syntax error, insert ";" to complete Statement - Syntax error on token "void", new expected - Syntax error, insert ")" to complete MethodInvocation - The method show() is undefined for the type Practice - Syntax error on token "void", delete this token - Syntax error, insert ";" to complete Statement */ //上面是错误信息,我把方法体去了也是这样 }
public static void main(String[] args) { }} 木有这么写的,块里面不可以写方法吧,怎么调用出来呢?就是啊,无法引用。java语法应该规定啊,这不是坑了我么
package classpackge;public class People{} class Student extends People {
public void show() { System.out.println("student ID "); } //////////////////////////////////////////////////////////////////////////////////// package mypackage; import classpackge.*; public class Practice {
public static void main(String[] args) { People people = new People(); // Student student = new Studnet(); //这里报错。我引入了包,为什么还会报错? // 是不是引入了包,只能访问包内的public类,引入包和同包是不同概念? } }
public class Practise {
static String string = "static filed";
static {
String strings = "static block";
}
static void show(){ //静态方法不可声明在静态块中
System.out.println("a method in static block");
}
public static void say() {
System.out.println(Practise.string);
// strings 在静态块中,属于方法内的变量,是局部的,外部访问不到
// System.out.println(strings); 如何使用strings?
}
public static void main(String[] args) {
Practise.say();
}
}
//Syntax error on tokens, AnnotationName expected instead
//Syntax error, insert ";" to complete Statement
Syntax error, insert ";" to complete Statement 语句后缺少;结束
{
static String string = "static filed";
static {
String strings = "static block";
void show(){} //这是什么错误,求解
/*Multiple ers at this line
- show cannot be resolved to a type
- Syntax error, insert ";" to complete Statement
- Syntax error on token "void", new expected
- Syntax error, insert ")" to complete
MethodInvocation
- The method show() is undefined for the type
Practice
- Syntax error on token "void", delete this token
- Syntax error, insert ";" to complete Statement
*/
//上面是错误信息,我把方法体去了也是这样
}
public static void main(String[] args) {
}}
就我的知识范畴:这个strings在静态块里面定义,外部无法调用
{
static String string = "static filed";
static {
String strings = "static block";
void show(){} //这是什么错误,求解
/*Multiple ers at this line
- show cannot be resolved to a type
- Syntax error, insert ";" to complete Statement
- Syntax error on token "void", new expected
- Syntax error, insert ")" to complete
MethodInvocation
- The method show() is undefined for the type
Practice
- Syntax error on token "void", delete this token
- Syntax error, insert ";" to complete Statement
*/
//上面是错误信息,我把方法体去了也是这样
}
public static void main(String[] args) {
}}
木有这么写的,块里面不可以写方法吧,怎么调用出来呢?
{
static String string = "static filed";
static {
String strings = "static block";
void show(){} //这是什么错误,求解
/*Multiple ers at this line
- show cannot be resolved to a type
- Syntax error, insert ";" to complete Statement
- Syntax error on token "void", new expected
- Syntax error, insert ")" to complete
MethodInvocation
- The method show() is undefined for the type
Practice
- Syntax error on token "void", delete this token
- Syntax error, insert ";" to complete Statement
*/
//上面是错误信息,我把方法体去了也是这样
}
public static void main(String[] args) {
}}
木有这么写的,块里面不可以写方法吧,怎么调用出来呢?就是啊,无法引用。java语法应该规定啊,这不是坑了我么
class Student extends People
{
public void show() {
System.out.println("student ID ");
}
////////////////////////////////////////////////////////////////////////////////////
package mypackage;
import classpackge.*;
public class Practice
{
public static void main(String[] args) {
People people = new People();
// Student student = new Studnet(); //这里报错。我引入了包,为什么还会报错?
// 是不是引入了包,只能访问包内的public类,引入包和同包是不同概念?
}
}