首页 > 代码库 > 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());
 }

}

 

java构造