下面是代碼:初學者;方法和字符串
import java.util.Scanner;
public class sending {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
String text = giveMe(first);
System.out.println(text);
int x = scanner.nextInt();
x = number(x);
skrivUt(x);
}
//method for printing on screen
public static String giveMe(String first, String second){
first = ("Give me a number and I run down and add five to it");
second = ("Lol");
return first;
}
//method for doing math
public static int number(int x){
x = x + 5;
return x;
}
//method for printing out
public static void skrivUt(int x){
System.out.println(x);
}
}
正如你看到的我是新來這和我有主要方法和方法giveMe問題。
我想讓giveMe工作作爲一個字符串的集合,我可以在需要時調用它們。
但是當我嘗試上面的例子中我日食告訴我,在六大行String text = giveMe(first);
我在做什麼錯「首先不能被解析爲一個變量」?
你應該閱讀有關變量_scope_。在'main'方法中,'first'是什麼? –
@SotiriosDelimanolis'第一個'是他看不見的'enum'。 – CodeCamper