问题很迷糊,这里长记性

最近的一些问题思考

前段时间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 希望可以试着做一个小网站

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值