This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Application { | |
| public static void main(String[] args) { | |
| int left = 5; | |
| int right = 6; | |
| //Arithmetic Operators | |
| System.out.println("Addition: " + (left + right)); | |
| System.out.println("Substraction: " + (left - right)); | |
| System.out.println("Multiplication: " + (left * right)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Application { | |
| public static void main(String[] args) { | |
| int left = 5; | |
| int right = 6; | |
| //Arithmetic Operators | |
| System.out.println("Addition: " + (left + right)); | |
| System.out.println("Substraction: " + (left - right)); | |
| System.out.println("Multiplication: " + (left * right)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Application { | |
| public static void main(String[] args) { | |
| //Numeric primitives | |
| int integerNumber = 1; | |
| Integer integerNumberRef = 1; | |
| short shortNumber = 32767; | |
| Short shortNumberRef = 32767; | |
| long longNumber = 373923; | |
| Long longNumberRef = 3713923L; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class App { | |
| public static void main(String[] args) { | |
| int myVariable = 55; | |
| int [] myArray = new int[3]; | |
| int[] myArray2 = {1, 2, 3}; | |
| myArray[0] = 1; | |
| myArray[1] = 2; | |
| myArray[2] = 3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Application { | |
| public static void main(String[] args) { | |
| int variable = 3; | |
| if ((variable != 5) && (variable == 0)){ | |
| System.out.println("Variable is greater than five."); | |
| } | |
| else if (variable == 5){ | |
| System.out.println("Else if here."); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Application { | |
| public static void main(String[] args) { | |
| for(int i = 0; i < 5; i++){ | |
| System.out.println(i); | |
| for(int k = 0; k < 5; k++){ | |
| System.out.println("This is the inner loop"); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Application { | |
| public static void main(String[] args) { | |
| int value = 10; | |
| do{ | |
| System.out.println("Value is: " + value); | |
| value += 1; | |
| } | |
| while(value < 20); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Application { | |
| public static void main(String[] args) { | |
| String text = new String(); | |
| text = "Hello"; | |
| String newString = text + " World!"; | |
| String newString2 = text.concat(" World!"); | |
| Integer number = 26; | |
| String numberStr = number.toString(); | |
| String text2 = "Hello2"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class App { | |
| public static void main(String[] args) { | |
| Scanner scanner = new Scanner(System.in); | |
| System.out.println("You need to type something: "); | |
| String input = scanner.nextLine(); | |
| System.out.println("User has typed: " + input); | |
| System.out.println("You need to type integer: "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class App { | |
| public static void main(String[] args) { | |
| Scanner scanner = new Scanner(System.in); | |
| System.out.println("You need to type something: "); | |
| String input = scanner.nextLine(); | |
| System.out.println("User has typed: " + input); | |
| System.out.println("You need to type integer: "); |
OlderNewer