最近的一些问题思考
前段时间JAVA语法基础算是磕磕绊绊的过来了
但是在学习面向对象却遇到了一些问题
有点绕脑子的操作
先创建一个学生类
//学生类
public class Student {
String name ;
int age;
String address;
Student(){}//方法构造
Student(String name,int age,String address){
this.name=name;
this.age=age;
this.address=address;
}
Student(String name,int age){
this(name,age,null);
}
Student(String name){
this(name,0,null);
}
void study(){
System.out.println(name+"在学习");
}
void sayHi(){
System.out.println(age+"岁"+address+"地址");
}
}
赋值有点一言难尽
int [] arr = new int [3];//基本数据类型数组
int [] arr = new int[]{
1,
2,
3
};
Student [] stus = new Student[3];//默认值age =0,name = null.address = null;
Student [] stus = new Student[]{
new Student("小柯",25,"中国");
new Student("小",20,"中国");
new Student("柯",18,"中国");
}
int[] [] arr = new int[3][];// 声明int[]数组arr;包含3个数组元素
arr[0] = new int[2];
arr[1] = new int[6];
arr[2] = new int[3];
arr[1][0] = 100;//给arr中第二个元素的第一个元素赋值100
最后一个代码段的理解
大盒子套小盒子!!!
eg| arr------------ int[][]
|arr[0]------------int[]
|arr[1] [0] -------int
//定义二维数组,每个数为100;
int[][]arr = new int[3][4];
for(int i=0;i<arr.length;i++){
for(int j =0;j<arr[i].length;j++){
arr[i][j] = 100;
System.out.print(arr[i][j]+" ");
}
System.out.println("");//矩阵----二维数组
继承与super有点小迷糊,索性贴在这涨涨记性
继承与超类中的问题
报错
class TestOne{
TestOne(int age){
}
}
class TestTwo extends TestOne{
TestTwo(){
super(5);
}
}
为了干饭加油
立下一个flag 希望可以试着做一个小网站