In tuna.java:
public
class
tuna {
public
void
simpleMessage(String name){
System.out.println("Hello"
+ name);
}
}
這含義是:
public
void
simpleMessage(String name) → 指定字符串的名字被稱為name
In
apples.java:
import
java.util.Scanner; →
從鍵盤輸入信息
class
apples{
public
static
void
main(String args[]){
Scanner input = new
Scanner(System.in);
tuna tunaObject = new
tuna ();
System.out.println("Enter
your name here: ");
String name = input.nextLine();
tunaObject.simpleMessage(name);
}
}
When
run this program,they will like this:
Enter
your name here:
Emily
→ 這是你的輸入
Hello
Emily →
Hello (你的輸入
)
沒有留言:
張貼留言