# Intro to Java ```java class HelloWorld{ void main(String[] args){ System.out.println("Hello, Matt"); } } ``` ```java String greeting = "Hello there!"; ``` ```java int myAge = 46; int myNewAge = myAge + 2; ``` ```java double myWeight = 144.5; ``` ```java Boolean isCool = false; if(isCool){ System.out.println("Welcome to the party"); } else { System.out.println("Get lost dweeeeeeb"); } ``` ```java int myAge = 46; while(myAge < 50){ System.out.println(myAge); myAge++; } ``` ```java for(int i = 0; i < 5; i++){ System.out.println(i); } ``` ```java String[] cars = {"Volvo", "Toyota", "Mazda"}; System.out.println(cars[1]); ``` ```java class HelloWorld{ void printMessage() { System.out.println("Hi"); } void main(String[] args){ printMessage(); } } ``` ```java class HelloWorld{ int add(int a, int b){ return a + b; } void main(String[] args){ int result = add(4, 2); System.out.println(result); } } ``` ```java class Human { String name; Human(String name){ this.name = name; } } class HelloWorld{ void main(String[] args){ Human matt = new Human("Matthew"); System.out.println(matt.name); } } ``` ```java class SuperHuman extends Human { private String power; SuperHuman(String name, String power){ super(name); this.power = power; } public String getPower(){ return this.power; } } class HelloWorld{ void main(String[] args){ SuperHuman superman = new SuperHuman("Clark", "flight"); superman.name = "bilbo"; System.out.println(superman.name); //superman.power = "burping"; System.out.println(superman.getPower()); } } ``` ```java abstract class Car { abstract void drive(); void stop(){ System.out.println("screeeeech"); } } class Sedan extends Car{ void drive(){ System.out.println("vroom"); } } class HelloWorld{ void main(String[] args){ Sedan myCar = new Sedan(); myCar.drive(); myCar.stop(); } } ``` ```java interface Bird { void fly(); } class Swallow implements Bird { public void fly() { System.out.println("sweeeee"); } } class HelloWorld{ void main(String[] args){ Swallow stewart = new Swallow(); stewart.fly(); } } ```