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