MUstar

IoT JAVA 0811 - TestJava.java

Aug 11th, 2017
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class TestJava {
  2.     int carSpeed;
  3.     public TestJava() {
  4.         System.out.println("default");
  5.         carSpeed = 100;
  6.         System.out.println("default : "+carSpeed);
  7.     }
  8.     public TestJava(int carSpeed) {
  9.         System.out.println("speed input");
  10.         this.carSpeed = carSpeed;
  11.         System.out.println("overload : "+carSpeed);
  12.     }
  13.     public void speedUp(){
  14.         carSpeed += 10;
  15.         System.out.println("Car Speed : "+carSpeed);
  16.     }
  17.     public void speedUp(int carSpeed){
  18.         this.carSpeed += carSpeed;
  19.         System.out.println("Car Speed : "+this.carSpeed);
  20.     }
  21.     public static void main(String args[]){
  22.         TestJava obj1 = new TestJava();
  23.         TestJava obj2 = new TestJava(150);
  24.         obj2.speedUp();
  25.         obj2.speedUp(30);
  26.     }
  27. }
RAW Paste Data