Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestJava {
- int carSpeed;
- public TestJava() {
- System.out.println("default");
- carSpeed = 100;
- System.out.println("default : "+carSpeed);
- }
- public TestJava(int carSpeed) {
- System.out.println("speed input");
- this.carSpeed = carSpeed;
- System.out.println("overload : "+carSpeed);
- }
- public void speedUp(){
- carSpeed += 10;
- System.out.println("Car Speed : "+carSpeed);
- }
- public void speedUp(int carSpeed){
- this.carSpeed += carSpeed;
- System.out.println("Car Speed : "+this.carSpeed);
- }
- public static void main(String args[]){
- TestJava obj1 = new TestJava();
- TestJava obj2 = new TestJava(150);
- obj2.speedUp();
- obj2.speedUp(30);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement