从方法里返回值

public class Fangfafanhuizhi {
    int giveSecret(){
        return 42;
    }
    public static void main(String[] args){
        Fangfafanhuizhi life = new Fangfafanhuizhi();
        
        int x = 0;
        System.out.println("赋值之前的X值="+x);
        
        x = life.giveSecret();
        System.out.println("赋值之后的x值="+x);
        
    }
}

 

 

 

posted @ 2016-08-13 16:05  特雷恩  阅读(103)  评论(0编辑  收藏  举报