java笔记(二)
1.不换行输出System.out.print(),换行输出System.out.println()
2.以此代码为例
package object2;
class student{
int age;
int id;
String sex;
}
public class People2 {
void speak(String name,student a){
System.out.println("我叫"+name+"我今年"+a.age+"我的id是"+a.id+"我是"+a.sex+"生");
}
public static void main(String args[]) {
student a= new student();
People2 hwx= new People2();
a.age=23;
a.id=16997;
a.sex="男";
hwx.speak("胡文轩", a);
}
}
在people2类中修改student类的age值如a.age=21时,相应的主函数中的a.age值并不会改变,但是单独输出一个a.age时会显示改变。(理解为在C盘内有个C文件夹值为21,C盘里还有个B文件夹,B文件夹里面还有个C文件夹值为23)
3.

浙公网安备 33010602011771号