for循环–简单猜数字小游戏 
- for循环格式:
   
	for( 单次表达式;条件表达式;末尾循环体  ){
	    中间循环语句;
	}
  
 
		Scanner 对象 = new Scanner();
 -      对象.nextInt (); 
 -      对象.close();
  
3、java-for循环--》》简单猜数字小游戏
  
public class Test{
	public static void main(String[] args){
		
		int x = (int)(Math.random()*100);
		
		Scanner player = new Scanner;
		
		System.out.println("请输入猜测的数字:");
		
		for(int i =0;i<10;i++){
			int y = player.nextInt();
			if(y<x){
				System.out.println("猜小了!!!");
			}else if(y>x){
				System.out.println("猜大了!!!");
			}else{
				System.out.println("猜对了~ ~ ~");
				return;
			}
			plaryer.close();
		}
		
	}
}
 
                
                
                
        
    
 
 |