Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Ultimate FREE Java Course Part 1

The Ultimate FREE Java Course Part 1

Have you ever seen a Java course that is 'visual' in nature? The kind of lessons where you can see what happens when you are creating an object, doing method overloading, and using run-time polymorphism. I bet you haven't. Welcome to the most 'visual' Java course you will ever take.

This course teaches you everything you need to get started with Java programming. It divides each topic into explanation and example.

The explanation section deals with how a particular concept works in Java and covers the following:

Data Types & Variables, Typecasting,
Operators & Conditional statements such as if, if else, switch
Loops such as for, for each, while, and do while
Methods, Types of methods, Call by Value vs. Call by Reference, Variable Scope, Method Overloading,
Arrays and ArrayLists,
Classes and objects, How classes and objects work, and How primitive types vs. reference types are stored
Swing classes to take input from the user and command line methods to take input from the user such as BufferedReader, Scanner, Console,
Static variables, static methods, this keyword, super keyword, method overriding,
What is inheritance
And a real world example of run-time polymorphism that actually demonstrates what happens with vs. without polymorphism.
The example section covers an example for every concept discussed above. The course will be updated constantly to keep in sync with the real world developments in Java. So, are you ready to become a Java PRO?

coursetro.com

August 03, 2016
Tweet

More Decks by coursetro.com

Other Decks in Programming

Transcript

  1. Agenda 1. Memory Organization 2. Data Hierarchy 3. Types of

    programming languages 4. Hello World 5. Steps to Run A Java Program 6. Type Conversions
  2. Agenda 8. If 9. Ternary Operator 10. for 11. while

    12. do while 13. break 14. continue
  3. Agenda 15. Strings 16. String Builder & Conversions 17. Methods

    & Types of methods 18. Method Overloading 19. Variable Scope 20. Arrays
  4. Mouse Display Printer Keyboard Main Memory Secondary Storage CPU Control

    Unit ALU CPU Storage Input Devices Output Devices
  5. 0 0 0 0 0 0 0 0 0 0

    1 0 1 0 1 1 0 1 V i v z Vivz 26 Vivz 26 Gary 32 Anky 26 Bit Unicode Letter V Field File Record or coursetro.com
  6. +1300042774 +1400593419 +1200274027 load pay add overtime store total total

    = pay + overtime Machine Level Assembly Level High Level coursetro.com
  7. Install Java JDK On Windows Install Java JDK On Mac

    Install IntelliJ On Windows Install IntelliJ On Mac Relevant Videos Click To Watch Videos Below
  8. Google It! • ASCII table • unicode table • ASCII

    vs Unicode • utf-8 means • utf-8 vs utf-16 • machine level language vs assembly language
  9. 1. println in Java 2. system.out.println 3. java system class

    4. java String 5. java main method 6. string args in java 7. void in java Google It!
  10. Memory Organization And Data Hierarchy Hello World Explained Hello World

    Example Steps To Run A Java Program Relevant Videos Click To Watch Videos Below
  11. 1. list of java editors 2. javac command 3. java

    command 4. java compiler vs interpreter 5. java classloader 6. java bytecode verifier 7. jvm in java 8. jvm vs jre 9. jvm vs jre vs jdk vs jit Google It!
  12. What is a variable? Storage location in a computer program.

    It has a name and value. Assign a value to it any number of times. coursetro.com
  13. byte myByte = 100; short myShort = 1000; int myInt

    = 100000; long myLong = 1000000; coursetro.com
  14. float myFloat = 125.124f; double myDouble = 125.214545544; char myChar

    = ‘C’; boolean condition = true coursetro.com
  15. What is a constant? It has a name and a

    value. You must assign the value while creating it and cannot change it afterwards. coursetro.com
  16. Type Conversion A small box can be fitted into a

    bigger box but vice versa is tricky. Implicit Type Conversion long long int int Explicit Type Conversion
  17. Variables And Constants Explained Variables And Constants Example Typecasting Explained

    Typecasting Example Relevant Videos Click To Watch Videos Below
  18. Modulus Operator • It gives you the remainder between 2

    numbers. 5 % 2 = 1 2 * 2 = 4 • 3 % 4 = 3 2 1 4 3 5 coursetro.com
  19. Expression • Expression in Algebra 1 + 2 + 3

    + 4+ 5 = 3 5 • Expression in Java (1 + 2 + 3 + 4+ 5) / 5 = 3 coursetro.com
  20. Operator Precedence In Java Arithmetic Operators are evaluated in the

    following order from first to last Multiplicative * / % Additive + - Example: 3 * 41 + 7 / 3 – 2 % 1 = ((3 * 41) + (7 / 3)) – (2 % 1) = 125.33 coursetro.com
  21. 1. explicit typecasting in java 2. implicit typecasting in java

    3. integer division in java 4. modulus operator can be applied to which of the following 5. java expression example 6. precedence of operators in java 7. associativity of operators in java Google It!
  22. Greater Than boolean result = 5 > 4; //Contains true

    int numOne = 5; int numTwo = 4; boolean result = numOne > numTwo; //Contains true coursetro.com
  23. Less Than boolean result = 5 < 4; //Contains false

    int numOne = 5; int numTwo = 4; boolean result = numOne < numTwo; //Contains false coursetro.com
  24. Greater Than Or Equal To boolean result = 5 >=

    4; //Contains true boolean result = 5 >= 5; //Contains true int numOne = 5; int numTwo = 4; boolean result = numOne >= numTwo; //Contains true coursetro.com
  25. Less Than Or Equal To boolean result = 5 <=

    4; //Contains false boolean result = 5 <= 5; //Contains true int numOne = 5; int numTwo = 4; boolean result = numOne <= numTwo; //Contains false coursetro.com
  26. Equals To boolean result = 5 == 4; //Contains false

    boolean result = 5 == 5; //Contains true int numOne = 5; int numTwo = 5; boolean result = numOne == numTwo; //Contains true coursetro.com
  27. Not Equals To boolean result = 5 != 4; //Contains

    true boolean result = 5 != 5; //Contains false int numOne = 5; int numTwo = 5; boolean result = numOne != numTwo; //Contains false coursetro.com
  28. += int numOne = 5; int numTwo = 4; //numOne

    = numOne + numTwo; numOne += numTwo; //Contains 9 coursetro.com
  29. -= int numOne = 5; int numTwo = 4; //numOne

    = numOne - numTwo; numOne -= numTwo; //Contains 1 coursetro.com
  30. *= int numOne = 5; int numTwo = 4; //numOne

    = numOne * numTwo; numOne *= numTwo; //Contains 20 coursetro.com
  31. /= int numOne = 9; int numTwo = 2; //numOne

    = numOne / numTwo; numOne /= numTwo; //Contains 4 coursetro.com
  32. %= int numOne = 5; int numTwo = 4; //numOne

    = numOne % numTwo; numOne %= numTwo; //Contains 1 coursetro.com
  33. Increment int year = 2050; newYear = year++; //Contains 2050

    newYear = year; year = year + 1; int year = 2050; newYear = ++year; //Contains 2051 year = year + 1; newYear = year; coursetro.com
  34. Decrement int year = 2050; newYear = year--; //Contains 2050

    newYear = year; year = year - 1; int year = 2050; newYear = --year; //Contains 2049 year = year - 1; newYear = year; coursetro.com
  35. ! A !A true false false true boolean engaged =

    false; boolean notEngaged = !engaged; coursetro.com
  36. && A B A && B true true true true

    false false false true false false false false boolean dcFan = true, marvelFan = true; if(dcFan && marvelFan){ System.out.println(“You like superheroes…”); }
  37. || A B A || B true true true True

    false true False true true false false false boolean dcFan = false, marvelFan = false; if(dcFan || marvelFan){ System.out.println(“You like some superhero, don’t you?”); } else{ System.out.println(“I guess not!”); }
  38. Assignment Operators Explained Assignment Operators Example Increment Decrement And Logical

    Operators Explained Increment Decrement And Logical Operators Example Relevant Videos Click To Watch Videos Below
  39. if If you get 90% or more this year I

    will get you a bike. if ( marks >= 90 ) { System.out.println(“You get a bike”); } coursetro.com
  40. if If you get more than 80% but less than

    90% you get a phone. if (marks >= 80 && marks < 90) { System.out.println(“You get a phone”); } coursetro.com
  41. If else If you pass, you get a chocolate Else

    no video games. if ( marks >= 40 ) { System.out.println(“Chocolate yay!”); } else { System.out.println(“No video games”); } coursetro.com
  42. If else ladder If marks greater than 90%, you get

    a bike, if marks are between 80-90% you get a phone, otherwise you get a chocolate, if you failed, then no video games if ( marks >= 90 ) { System.out.println(“You get a bike”); } else if (marks >=80){ System.out.println(“You get a phone”); } else if (marks>=40){ System.out.println(“Chocolate yay!”); } else { System.out.println(“No video games”); } coursetro.com
  43. Nested if else if marks greater than 90 and physical

    fitness examination score greater than 80 you get a car else you get a bike If marks less than 90 go to the gym if ( marks >= 90 ) { if (score>=80){ System.out.println(“You get a car”); } else { System.out.println(“You get a bike!”); } } else { System.out.println(“Go to the gym”); } coursetro.com
  44. 1. assignment vs equality operator in java 2. == vs

    = in java 3. java logical operators 4. dangling else problem in java 5. semicolon after if statement in java 6. short circuit evaluation in java Google It!
  45. Ternary Operator result = some condition ? An expression that

    returns some value if true : An expression that returns some value if it is false; coursetro.com
  46. If Else Explained If Else Example Ternary Explained Ternary Example

    Relevant Videos Click To Watch Videos Below
  47. Case Study If it is the first day, it is

    a Sunday… the second day is a Monday...the last day is a Saturday...anything else is not a day coursetro.com
  48. int day = 1; if(day == 1){ … (“It is

    a Sunday”); } else if (day == 2) { … (“It is a Monday”); } … else { … (“Not a valid day”); } coursetro.com
  49. int day = 1; switch(day){ case 1: … (“It is

    a Sunday”); break; case 2: … (“It is a Monday”); break; default: … (“Not a valid day”); break; } coursetro.com
  50. 1. break default java 2. switch fallthrough java 3. switch

    case expressions must be constant expressions 4. switch vs if else performance java 5. switch statement break after default Google It!
  51. Print Hello World 4 times : The Noob Way System.out.println(“Hello

    World”); System.out.println(“Hello World”); System.out.println(“Hello World”); System.out.println(“Hello World”); coursetro.com
  52. for for( initial value; loop continuation condition; increment) { //…something

    that you want to do a certain number of times } coursetro.com
  53. Print “Hello World” 4 times for(int i = 0; i

    < 4; i++){ …("Hello World"); } Initialization Check Condition Run the code inside Increment i = 0 0 < 4 = true Hello World i = 1 1 < 4 = true Hello World i = 2 i = 3 Hello World 2 < 4 = true 3 < 4 = true Hello World i = 4 4 < 4 = false coursetro.com
  54. Print “Hello World” 4 times for(int i = 1; i

    <= 4; i++){ …("Hello World"); } Initialization Check Condition Run the code inside Increment i = 1 1 <= 4 = true Hello World i = 2 2 <= 4 = true Hello World i = 3 i = 4 Hello World 3 <= 4 = true 4 <= 4 = true Hello World i = 5 5 <= 4 = false coursetro.com
  55. Print “Hello World” 4 times for(int i = 4; i

    > 0; i--){ …("Hello World"); } Initialization Check Condition Run the code inside Decrement i = 4 4 > 0 = true Hello World i = 3 3 > 0 = true Hello World i = 2 i = 1 Hello World 2 > 0 = true 1 > 0 = true Hello World i = 0 0 > 0 = false coursetro.com
  56. Vary the control variable from 1 to 10 in increments

    of 1. for (int i = 1; i <= 10; i++) Vary the control variable from 10 to 1 in decrements of 1. for (int i = 10; i >= 1; i--) Vary the control variable from 6 to 66 in increments of 6. for (int i = 6; i <= 66; i += 6) coursetro.com
  57. Vary the control variable from 30 to 3 in decrements

    of 3. for (int i = 30; i >= 3; i -= 3) Vary the control variable over the values 3, 7, 11, 15, 19. for (int i = 3; i <= 20; i += 4) Vary the control variable over the values 100, 89, 78, 67, 56, 45, 34, 23, 12 for (int i = 100; i >= 10; i -= 11) coursetro.com
  58. 1. java for statement 2. java for statement multiple conditions

    3. java for statement colon 4. java nested for loop number pyramid 5. java nested for loop exercises 6. java for loop off by one 7. java infinite for loop Google It!
  59. Print “Hello World” 4 times int i = 0; while(i

    < 4){ …("Hello World"); i++; } Initialization Check Condition Run the code inside i = 0 0 < 4 = true Hello World i = 1 1 < 4 = true Hello World i = 2 i = 3 Hello World 2 < 4 = true 3 < 4 = true Hello World i = 4 4 < 4 = false coursetro.com
  60. Print “Hello World” Till Condition Becomes False boolean condition =

    true; int i = 0; while(condition){ …("Hello World"); i++; if(i == 4){ condition = false; } } Initialization Condition Run the code inside i = 0 true Hello World i = 1 true Hello World i = 2 i = 3 Hello World true true Hello World i = 4 false Increment if 1 == 4 is false 2 == 4 is false 3 == 4 is false 4 == 4 is true So make condition = false
  61. 1. java while loop 2. java nested while loop 3.

    infinite while loop in java 4. while vs for loop java Google It!
  62. do…while do{ //…something that you want to do } while(

    some condition is true ); coursetro.com
  63. Print “Hello World” 4 times int i = 0; do

    { …("Hello World"); i++; } while(i < 4); Initialization Check Condition Run the code inside i = 0 Hello World i = 1 1 < 4 = true Hello World i = 2 i = 3 Hello World 2 < 4 = true 3 < 4 = true Hello World i = 4 4 < 4 = false coursetro.com
  64. while vs. do…while boolean condition = false; while(condition){ …(“Hello World”);

    } //Prints nothing boolean condition = false; do{ …(“Hello World”); } while(condition); //Prints Hello World coursetro.com
  65. While Explained While Example Do While Explained Do While Example

    Relevant Videos Click To Watch Videos Below
  66. 1. do while loop in java 2. do while vs

    while java 3. for vs while vs do while 4. infinite do while loop java 5. do while semicolon java Google It!
  67. break Break the cases in a switch Break loops Labelled

    break (covered in code) coursetro.com
  68. Break the cases of a switch int day = 0;

    switch(day){ case 0: …(“Sunday”); case 1: …(“Monday”); case 2: …(“Tuesday”); } Output Sunday Monday Tuesday int day = 0; switch(day){ case 0: …(“Sunday”); break; case 1: …(“Monday”); break; case 2: …(“Tuesday”); break; } Output Sunday coursetro.com
  69. Break Loops for(int i = 0; i < 9 ;

    i++) { …(i); if(i == 3){ break; } } Output 0 1 2 3 int i = 0; while(i < 9) { …(i); if(i == 3){ break; } i++; } Output 0 1 2 3 coursetro.com
  70. for(int i = 0; i < 9 ; i++) {

    if(i == 3){ continue; } …println(i); } Output 0 1 2 4 5 6 7 8 int i = 0; while(i < 9) { i++; if(i == 3){ continue; } …println(i); } Output 1 2 4 5 6 7 8 9 coursetro.com
  71. 1. break statement in java 2. break out of loops

    java 3. labelled break in java 4. continue statement in java 5. break vs continue in java 6. labelled continue in java Google It!
  72. What are Strings Strings are simply a sequence of characters

    defined inside “” Examples: “Hello” “123” “!@#$%^&*(” “NB *(*(&GB86786rfyv” coursetro.com
  73. Creating a String • String str = “Hello String”; •

    String nullStr = null; nullStr = “Hello String”; • String newStr = new String(“Hello String”); • String string = String.valueOf(“Hello String”); Using String class coursetro.com
  74. Concatenating Strings String str = “Hello”; // Hello str +=

    “World”; // Hello World str = str + “!”; // Hello World ! str.concat(“ Again”); // Hello World ! Again coursetro.com
  75. Whose equal? String s1 = “Hello”; String s2 = “Hello”;

    String s3 = “Bye”; String s4 = new String(“Hello”); String s5 = “hello”; s1 == s2 ; // true s1 == s4; // false s1.equals(s4); // true s1.equalsIgnoreCase(s5); // true s1.equals(s3); // false Hello Bye Hello hello coursetro.com
  76. str.indexOf('e');// 1 str.indexOf("ello"); // 1 str.indexOf('o', 5); // 7 str.charAt(3);

    // l str.substring(3); // lo World H e l l o W o r l d 0 1 2 3 4 5 6 7 8 9 10 coursetro.com
  77. str.substring(3, 9); // lo Wor str.contains("Z"); // false "".isEmpty(); //

    true str.toUpperCase(); // HELLO WORLD str.toLowerCase(); // hello world H e l l o W o r l d 0 1 2 3 4 5 6 7 8 9 10 coursetro.com
  78. “ Hello ”.trim(); // Hello "Potatoes, Apples, Oranges".split(","); // [“Potatoes”,

    “Apples”, “Oranges”] str.join(",", "Apples", "Oranges", "Potatoes"); // “Apples,Oranges,Potatoes” H e l l o W o r l d 0 1 2 3 4 5 6 7 8 9 10 coursetro.com
  79. 1. java string class 2. java String.valueOf 3. java string

    length 4. java string concat 5. string concat vs + in java 6. java escape special characters 7. java string equals 8. equals vs == in java 8. java string indexof 9. java string equalsignorecase 10. java string charat 11. java string substring 12. java string contains 13. java check empty string 14. java string trim 15. Java string join Google It!
  80. Creating a String Builder StringBuilder sb= new StringBuilder(); sb.append("Hello"); StringBuilder

    sb= new StringBuilder("Hello Again"); StringBuilder sb= new StringBuilder(5); sb.append("Hello One more time"); coursetro.com
  81. Concatenation StringBuilder sb = new StringBuilder("Hello"); // Hello sb.append(“World”); //

    Hello World sb.append(“!”); // Hello World ! coursetro.com
  82. Methods StringBuilder sb = new StringBuilder("Hello"); // Hello sb.append(" Again");

    // Hello Again sb.insert(5, "2"); // Hello2 Again sb.replace(5, sb.length(), " World"); // Hello World sb.delete(5, 11); // Hello sb.deleteCharAt(4); // Hello coursetro.com
  83. Conversions to String byte b = 1; String result =

    String.valueOf(b); short s = 12; String result = String.valueOf(s); String result = String.valueOf(123); char letter = ‘A’; String result = String.valueOf(letter); coursetro.com
  84. Conversions to String long l = 1224; String result =

    String.valueOf(l); String result = String.valueOf(23.32f); String result = String.valueOf(12.34); String result = String.valueOf(true); coursetro.com
  85. Conversions from String String value = “12”; byte b= Byte.parseByte(value);

    String value = “123”; short s= Short.parseShort(value); int i = Integer.parseInt(“123”); String value = “A”; char c =value.charAt(0); coursetro.com
  86. Conversions from String String value = “1254”; long l =

    Long.parseLong(value); float f= Float.parseFloat(“23.42F”); double d = Double.parseDouble(“12.3456”); boolean b =Boolean.parseBoolean(“false”);
  87. Click to watch videos below String Explained String Example I

    String Example II String Builder And String Conversions Explained String Builder And String Conversions Example
  88. 1. java stringbuffer class 2. java stringbuilder class 3. string

    vs stringbuffer 4. string vs stringbuilder 5. stringbuffer vs stringbuilder 6. stringbuilder append 7. stringbuilder delete 8. stringbuilder insert 9. stringbuilder replace 10. stringbuilder to string 11. integer.parseint 12. float.parsefloat 13. double.parsedouble 14. string.valueof Google It!
  89. What are methods ? A group of instructions that which

    you can name. Calling the name runs all the instructions in that group. Sure Boss. Send that email coursetro.com
  90. Add 2 numbers without methods Add 2 + 5 int

    num1 = 2, num2 = 5; int sum = num1 + num2; Add 3 + 7 int num1 = 3, num2 = 7; int sum = num1 + num2; coursetro.com
  91. Why repeat yourself? Bunch the 2 lines together! { int

    num1 = 2, num2 = 5; int sum = num1 + num2; } coursetro.com
  92. Give that bunch a name add(){ int num1 = 2,

    num2 = 5; int sum = num1 + num2; } coursetro.com
  93. Call the name() to add 2 + 5 every time

    add(); Its like calling your assistant Wait, who wants to add 2 + 5 every time? coursetro.com
  94. Assistant says, “Give me the numbers, I will add them”

    add(int num1, int num2){ int sum = num1 + num2; } coursetro.com
  95. What should the assistant do after adding? Display the result?

    Print them on a printer? Email the boss? Why not tell your assistant to give the results back to the boss? coursetro.com
  96. Assistant says it will return an integer int add(int num1,

    int num2){ int sum = num1 + num2; return sum; } coursetro.com
  97. Boss is free to do whatever he/she wants with the

    result int result = add(3, 7); …println(result); coursetro.com
  98. Assistant says “I will display the value but I wont

    give the boss any result” void add(int num1, int num2){ int sum = num1 + num2; …println(sum); } coursetro.com
  99. Boss calls the assistant to display the result add(3, 7);

    The assistant’s code has a println() remember? coursetro.com
  100. 1. java methods example 2. java method vs function 3.

    java method signature 4. java argument promotion and casting 5. java method overloading 6. java method call stack Google It!
  101. Kinds of Methods • Methods that take no input and

    give no result back. • Methods that take input and give no result back. • Methods that take no input and give some result back. • Methods that take input and give some result back. coursetro.com
  102. No instructions, With reporting Boss Assistant boolean outcome = public

    boolean sendEmail(){ //code written to send email return success; } Reporting sendEmail() coursetro.com
  103. Instructions included, no reporting Boss Assistant sendEmail( “[email protected]”, ”Hello”, “I

    would love to buy your course”) public void sendEmail(String to, String subject, String message){ //code written to send email to the //person with the subject and message } Instructions coursetro.com
  104. Instructions included, With reporting Boss Assistant boolean outcome = public

    boolean sendEmail(String to, String subject, String message){ //code written to send email to the //person with the subject and message return success; } Instructions Reporting sendEmail( “[email protected]”, ”Hello”, “I would love to buy your course”) coursetro.com
  105. Assistant handling 1 set of instructions Boss Assistant Instructions [to

    whom, subject, message] Reporting coursetro.com
  106. Multiple assistants with same name Boss Assistant Instructions [to whom,

    subject, message] Reporting Instructions [to whom, subject, message, attachment] coursetro.com
  107. Boss Assistant boolean outcome = sendEmail( “[email protected]”, ”Hello”, “I would

    love to buy your course”) //OR public boolean sendEmail(String to, String subject, String message){ //code written to send email to the //person with the subject and message return success; } Instructions Reporting boolean outcome = sendEmail( “[email protected]”, ”Hello”, “I would love to buy your course”, …) public boolean sendEmail(String to, String subject, String message, Object attachment){ //code written to send email to the //person with the subject and message return success; } coursetro.com
  108. What is variable scope? Scope = part of the program

    where you can access your variable… coursetro.com
  109. Example 1 public static void main(String[] args){ System.out.println(volumeOfCube(10.0)); } public

    static double volumeOfCube(double length){ return length * length * length; } length is called a local variable and can be accessed or used only inside the blue box Scope = within {} where it was created
  110. Example 2 Both i and square can be accessed or

    used only inside the green box Scope = within {} where it was created public static void main(String[] args){ int sum = 0; } for(int i = 0 ; i <= 10 ; i++ ) { int square = i * i; sum = sum + square; }
  111. Same variable name in different scopes public static void main(String[]

    args){ int result = square(5); }; public static double square(int number){ int result = number * number; return result; } Variables created inside different boxes can have the same name
  112. Click to watch videos below Methods Explained Types of Methods

    Methods Example Method Overloading And Variable Scope Explained Method Overloading And Variable Scope Example
  113. 1. java method variable scope 2. java method overloading 3.

    java method overloading rules Google It!
  114. What is an array ? It’s a collection of variables

    of fixed size and same type. Collection of integers. Collection of Booleans Collection of Characters 1 5 2 0 true false false true ‘c’ ‘r’ ‘q’ ‘t’
  115. Representation of an Array Every item in an Array has

    a location Location starts from 0, not 1 Length = 9, last position in the above array = 8 In Memory Locati on 0 1 2 3 4 5 6 7 8 Value C o u r s e t r o coursetro.com
  116. Method A int [] numbers; numbers = new int[10]; numbers[5]

    = 26; int[] 0 0 0 0 0 26 0 0 0 0 0 1 2 3 4 5 6 7 8 9
  117. Method B int[] numbers = {0, 0, 45, 18}; int[]

    0 0 45 18 0 1 2 3 coursetro.com
  118. Array References int[] scores = {10, 9, 7, 6, 8};

    int[] values = scores; scores[3] = 10; System.out.println(values[3]); //Prints 10 int[] 10 9 7 6 8 0 1 2 3 4 scores = values = 10 9 7 10 8 0 1 2 3 4 coursetro.com
  119. Reading values from Arrays. Using for loop: int[] numbers =

    {4,1,5,7,8}; for( int i = 0 ; i < numbers.length ; i++ ) { …(“Value at index ” + i + “ is: “ + numbers[i] ); } coursetro.com
  120. Reading values from Arrays. Using while loop: int[] numbers =

    {4,1,5,7,8}; int counter = 0; while( counter < numbers.length ){ …(“Value at index ” + i + “ is: “ + numbers[i] ); counter += 1; } coursetro.com
  121. Reading values from Arrays. Using for-each loop: int[] numbers =

    {4,1,5,7,8}; for( int i : numbers ) { …(“Value “ + i ); } coursetro.com
  122. Send email to an array of addresses Boss Assistant String[]

    to = { “[email protected]”, “[email protected]”, ”[email protected]”}; sendEmail(to) public void sendEmail(String[] to){ //code written to send ‘hello there’ //email to the person } Instructions coursetro.com
  123. Send and receive arrays from a method Boss Assistant String[]

    to = { “[email protected]”, “[email protected]”, ”[email protected]”}; boolean[] outcomes = sendEmail(to) public boolean[] sendEmail(String[] to){ boolean[] successes = … //code written to send hello to everyone return successes; } Instructions Reporting coursetro.com
  124. 1. java array with variable size 2. java array declaration

    3. java array initialization 4. where are arrays stored in memory in java 5. java string array 6. java character array 7. char array to string java 8. string to char array java 9. java for each loop Google It!
  125. Single dimensional Array int[] numbers = {9,8,7,6}; int[][] numbers =

    { {9,8,7}, {6,5,4}, {3,2,1} }; Position 0 1 2 3 Value 9 8 7 6 Position Col 0 Col 1 Col 2 Row 0 9 8 7 Row 1 6 5 4 Row 2 3 2 1
  126. Multi dimensional Array int[][] numbers; numbers = new int[3][3]; numbers[0][0]

    = 9; … numbers[2][2] = 1; Position Col 0 Col 1 Col 2 Row 0 9 8 7 Row 1 6 5 4 Row 2 3 2 1 coursetro.com
  127. Print column wise We want to print: column 0, column

    1, column 2 for row 0 column 0, column 1, column 2 for row 1 column 0, column 1, column 2 for row 2 We want to print column c for row r Position Col 0 Col 1 Col 2 Row 0 9 8 7 Row 1 6 5 4 Row 2 3 2 1 coursetro.com
  128. Print column wise If we wanted to print only the

    first row: for(int c = 0; c < 3; c++){ …(numbers[0][c]); } Position Col 0 Col 1 Col 2 Row 0 9 8 7 Row 1 6 5 4 Row 2 3 2 1 coursetro.com
  129. Print column wise If we wanted to print all rows

    and all columns: for(int r = 0; r < 3; r++){ //Increase the rows by 1 after inner loop runs for(int c = 0; c < 3; c++){ //Increase the column by 1 each time …(numbers[r][c]); } } Position Col 0 Col 1 Col 2 Row 0 9 8 7 Row 1 6 5 4 Row 2 3 2 1 coursetro.com
  130. Multidimensional Array 0 1 2 0 9 8 7 1

    6 5 4 2 3 2 1 Jagged Array 0 1 2 9 8 6 7 5 4 0 1 2 int[][] numbers = new int[3][3]; numbers[0][0] = 9; … numbers[2][2] = 1; int[][] numbers = new int[3][ ]; numbers[0] = new int[1]; numbers[1] = new int[2]; numbers[2] = new int[3]; numbers[0][0]=9; … numbers[2][2]=4; coursetro.com
  131. 1. java multidimensional array 2. Java multidimensional array length 3.

    java jagged array 4. java jagged array length Google It!