課程
/后端開發(fā)
/Java
/Java入門第一季(IDEA工具)升級版
這個怎么輸出呢?每個“three”都不一樣的值,每次需要給賦值到一個變量中嗎?如果不賦值最后要怎樣才能把那幾個數(shù)值全部輸出呢?
2016-09-22
源自:Java入門第一季(IDEA工具)升級版 3-3
正在回答
public class HelloWorld{
? ? public static void main(String[] args) {
? ?int one = 10 ;
? ? ? ? int two = 20 ;
? ? ? ? int three = 0 ;
? ? ? ? three=one+two;
? ? ? ? System.out.println(three);
? ? ? ? three+=one;
? ? ? ? three-=one;
? ? ? ? three*=one;
? ? ? ? three/=one;
? ? ? ? three%=one;
}
//每個“three”都不一樣的值,每次需要給賦值到一個變量中嗎?
//只有一個變量,名字叫所three。每次變化后輸出即可!??!
public class Fanch {
public static void main(String[] args){
int one=10;
int two=20;
int three=0;
int t1=three=one+two;
int t2=three+=one;
int t3=three-=one;
int t4=three*=one;
int t5=three/=one;
int t6=three%=one;
System.out.println(t1);
System.out.println(t2);
System.out.println(t3);
System.out.println(t4);
System.out.println(t5);
System.out.println(t6);
我是這樣的,也對的,但是覺得有點(diǎn)麻煩。還是一樓分別賦值輸出好用
因?yàn)楦淖兊木褪莟hree的值,one two是不變的,
寫完一條運(yùn)算,跟一條輸出語句
three = one + two;
System.out.println("one + two="+three);
舉報(bào)
0基礎(chǔ)萌新入門第一課,從Java環(huán)境搭建、工具使用、基礎(chǔ)語法開始
1 回答怎么不賦值就輸出了?
3 回答怎么沒有賦值就直接輸出了?
4 回答怎么把輸入的值賦值給today?
3 回答賦值變量輸出問題
3 回答直接賦值 和重新賦值有什么區(qū)別?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-09-22
public class HelloWorld{
? ? public static void main(String[] args) {
? ?int one = 10 ;
? ? ? ? int two = 20 ;
? ? ? ? int three = 0 ;
? ? ? ? three=one+two;
? ? ? ? System.out.println(three);
? ? ? ? three+=one;
? ? ? ? System.out.println(three);
? ? ? ? three-=one;
? ? ? ? System.out.println(three);
? ? ? ? three*=one;
? ? ? ? System.out.println(three);
? ? ? ? three/=one;
? ? ? ? System.out.println(three);
? ? ? ? three%=one;
? ? ? ? System.out.println(three);
}
}
//每個“three”都不一樣的值,每次需要給賦值到一個變量中嗎?
//只有一個變量,名字叫所three。每次變化后輸出即可!??!
2016-10-09
public class Fanch {
public static void main(String[] args){
int one=10;
int two=20;
int three=0;
int t1=three=one+two;
int t2=three+=one;
int t3=three-=one;
int t4=three*=one;
int t5=three/=one;
int t6=three%=one;
System.out.println(t1);
System.out.println(t2);
System.out.println(t3);
System.out.println(t4);
System.out.println(t5);
System.out.println(t6);
我是這樣的,也對的,但是覺得有點(diǎn)麻煩。還是一樓分別賦值輸出好用
2016-09-22
因?yàn)楦淖兊木褪莟hree的值,one two是不變的,
2016-09-22
寫完一條運(yùn)算,跟一條輸出語句
three = one + two;
System.out.println("one + two="+three);