zoukankan      html  css  js  c++  java
  • java构造

    import java.util.Scanner;


    public class hey {

     /**
      * @param args
      */
         static int a,b;
         private static int add(int a,int b)
        {
         return a+b;
        }
         private static double add(double a,double b){
          return a+b;
         }
         private static String add(String a,String b)
         {
          return a+b;
         }
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      Scanner cin=new Scanner (System.in);
      String a,b;
      int m,n;
      while(true)
      {
       a=cin.next();
       b=cin.next();
       System.out.println(add(a,b));
       m=cin.nextInt();
       n=cin.nextInt();
       System.out.println(add(m,n));
      }
      
     }

    }


    public class Student {
       private String name;
       private int age;
       private String Address;
       private String tel;
      
       public Student(String name,int age,String Address,String tel)
       {
        this.name=name;
        this.Address=Address;
        this.age=age;
        this.tel=tel;
       }
    public String getName() {
     return name;
    }
    public void setName(String name) {
     this.name = name;
    }
    public int getAge() {
     return age;
    }
    public void setAge(int age) {
     this.age = age;
    }
    public String getAddress() {
     return Address;
    }
    public void setAddress(String address) {
     Address = address;
    }
    public String getTel() {
     return tel;
    }
    public void setTel(String tel) {
     this.tel = tel;
    }
      
    }


    public class Test {

     /**
      * @param args
      */
     public static void main(String[] args) {
      // TODO Auto-generated method stub
            //Student s1=new Student();
            Student s2=new Student("Hello",13,"adada","123456789");
            System.out.println("Name="+s2.getName()+" Age="+s2.getAge()+" Address="+s2.getAddress()+" Tel="+s2.getTel());
     }

    }

  • 相关阅读:
    JavaScript对象 原型
    JavaScript数据类型 数据转换
    JavaScript字符串去除空格
    JavaScript实现StringBuffer
    JavaScript获取url参数
    JavaScript获取当前根目录
    React 和 Redux理解
    Umbraco 中获取一个media item的文件路径 file path
    Umbraco中获取UmbracoContext
    Umbraco中如何找到home node
  • 原文地址:https://www.cnblogs.com/xiaziteng/p/4013949.html
Copyright © 2011-2022 走看看