本人编写的这样一个方法的程序是用方法的调用但是没有成功错误在init()!本人才用到方法不太熟悉
请各为大哥指点如何才能写好方法!有没有固定的格式!谢谢!
package untitled3;
import java.io.*;
public class number{
/**
* init
*/
public void init() {
double y=0;
int x=0;
y=x+0.5;
System.out.println("得数为:"+y);
}
public static void main(String arg[]){
int x=0;
String s=" ";
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入一个数:");
s=in.readLine();
x=Integer.parseInt(s);
}catch(IOException e){}
init();
}
}
请各为大哥指点如何才能写好方法!有没有固定的格式!谢谢!
package untitled3;
import java.io.*;
public class number{
/**
* init
*/
public void init() {
double y=0;
int x=0;
y=x+0.5;
System.out.println("得数为:"+y);
}
public static void main(String arg[]){
int x=0;
String s=" ";
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入一个数:");
s=in.readLine();
x=Integer.parseInt(s);
}catch(IOException e){}
init();
}
}
n.init();本贴解决方法已在你的另外一张贴中贴出来了
public static void init() {
}
改為這樣吧.