已知两个变量x,y,利用条件运算符写1条语句,求出其中的大者,并将大者的值赋给z。/**Tochangethistemplate,chooseTools|Templates*andopenthetemplateintheeditor.*/packagetest;imp...
已知两个变量x,y ,利用条件运算符写1条语句,求出其中的大者,并将大者的值赋给z。
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.io.*;
/**
*
* @author catherine
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int i ;
int j ;
int z ;
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
i = Integer.parseInt(br.readLine()); //输入i
j = Integer.parseInt(br.readLine());//输入j
}catch(IOException ex){}
z=i>j? i:j;//错误提示:可能尚未初始化变量 i,我在上边不是有输入i、j的值吗?错哪?该如何改正?
System.out.println("i="+i);
System.out.println("j="+j);
System.out.println("z="+z);
}
}
————————————————
谢谢~!
展开