zoukankan      html  css  js  c++  java
  • java9

    十四章
         1.方法定义
            public 返回值类型 方法名(参数类型1 参数名1,参数类型2 参数名2···){
            //方法体
            }
         2.有参数的调用
            a.如果同一个类中,方法可以直接调用。
            b.如果是不同的类,方法必须通过对象调用,
              对象名,方法名(实参1,实参2···);
           注意:1.实参的数据类型,参数的个数,参数的顺序要与形参保持一致
                 2.调用返回值的方法,一般要接收返回值,并作出相应的处理。
    
    
    public class Excelle {
        private String type;
        private String id;
        public Excelle(){
            
        }
        
        public  Excelle(String type,String id ){
            this.type = type;
            this.id = id;
        }
        public String getType(){
            return type;
        }
        public String getId(){
            return id;
        }
    
    }
    
    
    public class Excelle {
        public     static void main(String[] args){
            Seller sl = new Seller();
            Excelle car = new Excelle("abc","1");
            sl.sell(car);
            Regal rl = new  Regal("bbb","2");
            sl.sell(rl);
            Excelle ec = new Excelle("ccc","3");
            sl.sell(ex,5);
        }
    }
    
    
    public class Student {
        String name;
        int age;
        String sex;
        String subject;
        public Student(){
            
        }
        
        public Student(String name,int age,String sex,String subject){
            this.name = name;
            this.age = age;
            this.sex = sex;
            this.subject = subject;
        }
        public String getName(){
            return name;
        }
        public int getAge(){
            return age;
        }
        public String getSex(){
            return sex;
        }
        public String getSubject(){
            return subject;
        }
        public void wj(){
            System.out.println("我是"+this.name+"年龄"+this.age+"性别"+this.sex+"专业"+this.subject);
        }
    }
    
    
    
    public class Student{
        public static void main(String[] args){
            Student s = new Student("xy",18,"nan","aaa");
            s.getAge();
            s.getName();
            s.getSex();
            s.getSubject();
            s.wj();
        }
    }
  • 相关阅读:
    计算函数执行时间
    Go语言生成随机数
    413 Request Entity Too Large
    JavaScript变量与数据类型详解
    OAuth2.0认证详解
    prompt的工作原理
    JS 实现上传图片
    移动端的长按事件的实现
    实现自动关闭当前页面的效果
    前端异常捕获与上报
  • 原文地址:https://www.cnblogs.com/wojiatingting/p/6962678.html
Copyright © 2011-2022 走看看