Advertisement
MUstar

IoT JAVA 0811 - TestJava.java

Aug 11th, 2017
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement