├── 1. Introduction.java ├── 2. Functions.java ├── 3. Arrays.java ├── 4. Strings.java ├── 5. Iteration.java ├── 6. Indexed Iteration.java ├── 7. Neighboring Indices.java ├── 8. Cloning.java ├── 9. Review.java ├── LICENSE └── README.md /1. Introduction.java: -------------------------------------------------------------------------------- 1 | class Main { // name of the class comes from the name of the file 2 | // this is the main method 3 | // this is the first thing that java will run when you run the java file 4 | public static void main(String[] args) { 5 | 6 | // Building blocks of programming 7 | // - Variables 8 | // - If Statements 9 | // - Loops 10 | // - Data Structures (Array) 11 | 12 | // These are Comments 13 | // These lines are ignored by the code editor 14 | 15 | // Printing 16 | // This is how we get stuff to show up in the 17 | // console 18 | 19 | // There are two variants 20 | System.out.println(123); 21 | System.out.println("David"); 22 | 23 | System.out.print(123); 24 | System.out.print(456); 25 | 26 | // println will print whatever is in the parenthesis 27 | // and then put the cursor at the next line... 28 | 29 | // print will print whatever is in the parenthesis 30 | // and then keep the cursor at the same line... 31 | 32 | // Data Types 33 | // - int (Integer) - whole numbers 34 | // - double (Double) - anything with a decimal point (5.0) 35 | // - boolean (Boolean) - true / false 36 | // - String - anything in quotation marks 37 | 38 | // When declaring a variable... you have to declare 39 | // its data type 40 | 41 | // dataType variable_name = value; 42 | int x = 5; 43 | 44 | // Once a variable is declared, it cannot be declared again 45 | // String x = "hello"; this does not work 46 | // x = true; this does not work 47 | 48 | x = 10; 49 | 50 | // print statements can print out numbers... strings... 51 | // and variables 52 | 53 | System.out.println(x); 54 | 55 | // Operators 56 | // These are used to create expressions 57 | // Arithmetic, Relational, Logical 58 | 59 | // Arithmetic 60 | // + - * / 61 | // % - modulus 62 | 63 | System.out.println(5 + 5); 64 | 65 | // Follow order of operations 66 | // Parenthesis 67 | // Exponents 68 | // Multiplication Division Modulus 69 | // Addition Subtraction 70 | 71 | // If there is no order of operation being applied... 72 | // Java will evaluate the expressions left to right 73 | // AND Java can only evaluate one operator at a time 74 | 75 | System.out.println(1 + 2 + 3); 76 | // (1 + 2) + 3 77 | // 3 + 3 78 | // 6 79 | 80 | System.out.println(1 + 2 * 3); 81 | // 1 + (2 * 3) 82 | // 1 + 6 83 | // 7 84 | 85 | // evaluating = return 86 | 87 | // In Java... anytime a double is involved in an expression 88 | // the result will always be as a double 89 | 90 | System.out.println(5 / 1.7); 91 | 92 | // But... if only integers are involved... the answer will 93 | // always be an integer 94 | // Integers will always round down 95 | 96 | System.out.println(5 / 2); 97 | 98 | // Modulus 99 | // The remainder of division 100 | 101 | // 5 / 2 = 2.5 or 2 (1)/2 102 | 103 | // 5 - 2 104 | // 3 - 2 105 | // 1 106 | 107 | System.out.println(5 % 2); 108 | 109 | System.out.println(4 % 2); // 0 110 | System.out.println(7 % 3); // 1 111 | System.out.println(8 % 3); // 2 112 | System.out.println(9 % 3); // 0 113 | System.out.println(10 % 3); // 1 114 | System.out.println(11 % 3); // 2 115 | 116 | // 0 % anything is always divisible 117 | 118 | System.out.println(0 % 10); 119 | 120 | System.out.println(5 * 5 / 5); 121 | System.out.println(5 / 5 * 5); 122 | 123 | // Lets take a break until 2PM 124 | 125 | // Relational Operators 126 | // > < >= <= 127 | // == != 128 | // Result in a boolean (true / false) 129 | // 5 > 2 130 | 131 | System.out.println(5 > 2); 132 | System.out.println(5 < 2); 133 | 134 | // = in Math represents equality 135 | // = in programming for assignment/change 136 | 137 | int y = 10; 138 | y = 15; 139 | 140 | // == in programming for equality 141 | System.out.println(5 == 5); 142 | System.out.println(5 == 4); 143 | // != in programming for inequality 144 | System.out.println(5 != 5); // false 145 | System.out.println(5 != 4); // true 146 | 147 | // Combining Relational operators with Arithmetic operators 148 | 149 | System.out.println(5 + 5 >= 15 - 5); 150 | 151 | // Arithmetic operators have priority over relational operators 152 | 153 | // (5 + 5) >= 15 - 5 154 | // 10 >= (15 - 5) 155 | // 10 >= 10 156 | // true 157 | 158 | // 5 < x < 15 this does not work in programming 159 | // Java evaluates one operator at a time 160 | 161 | // (5 < x) < 15 162 | // true < 15 163 | 164 | // Logical Operators 165 | // These operators allow us to combine multiple relational 166 | // operators 167 | // && (and) || (or) ! (not) 168 | 169 | // The && operator checks on both sides and evaluates 170 | // the relational expressions on each side and returns true 171 | // if both sides are true 172 | 173 | int z = 0; 174 | 175 | // 5 < z < 15 176 | 177 | System.out.println(5 < z && z < 15); 178 | 179 | // (5 < z) && z < 15 180 | // false && (z < 15) 181 | // false && true 182 | // false 183 | 184 | // The || operator only needs at least one side to be true 185 | // for the entire expression to be true 186 | 187 | // z < 5 or z > 15 188 | 189 | // with or operators, be careful constructing expressions 190 | // that are always true 191 | 192 | System.out.println(z < 5 || z > 15); 193 | 194 | // Arithmetic > Relational > Logical 195 | 196 | // Within logical operators, && has precedence over the || 197 | 198 | System.out.println(5 + 5 > 7 && 5 * 4 > 7 * 3); 199 | 200 | // 5 + 5 > 7 && (5 * 4) > 7 * 3 201 | // 5 + 5 > 7 && 20 > (7 * 3) 202 | // (5 + 5) > 7 && 20 > 21 203 | // (10 > 7) && 20 > 21 204 | // true && (20 > 21) 205 | // (true && false) 206 | // false 207 | 208 | System.out.println(5 * 2 / 3 > 12 % 8 || 7 + 2 * 3 == 17 / 4); 209 | 210 | // (5 * 2) / 3 > 12 % 8 || 7 + 2 * 3 == 17 / 4 211 | // (10 / 3) > 12 % 8 || 7 + 2 * 3 == 17 / 4 212 | // 3 > (12 % 8) || 7 + 2 * 3 == 17 / 4 213 | // 3 > 4 || 7 + (2 * 3) == 17 / 4 214 | // 3 > 4 || 7 + 6 == (17 / 4) 215 | // 3 > 4 || (7 + 6) == 4 216 | // (3 > 4) || 13 == 4 217 | // false || (13 == 4) 218 | // (false || false) 219 | // false 220 | 221 | int a = 10; 222 | int b = 15; 223 | 224 | System.out.println(b < 10 || a > 5 && a < 10); // false 225 | 226 | // (b < 10) || a > 5 && a < 10 227 | // false || (a > 5) && a < 10 228 | // false || true && (a < 10) 229 | // false || (true && false) 230 | // (false || false) 231 | // false 232 | 233 | // ! not 234 | // negates the result of a boolean expression 235 | 236 | System.out.println(!true); 237 | System.out.println(!false); 238 | 239 | // This wraps up the basics of Java 240 | 241 | // The second building block is the if statement 242 | // This is where we begin to form logic 243 | 244 | // if(boolean expression) { 245 | 246 | // } 247 | 248 | // curly brackets will tell java what code belongs to what 249 | 250 | // anything that belongs to an if statement will only run 251 | // if the boolean expression in the parenthesis is true 252 | 253 | int c = 10; 254 | if(c > 5) { 255 | System.out.println(12345); 256 | } 257 | 258 | // every time you use the keyword if, it starts an if block 259 | // an if block is independent of every other if block 260 | 261 | // GOAL: is to learn more about the data that we are checking 262 | // in the if statement 263 | 264 | // MINDSET: we do not know what the value of our variables are 265 | 266 | // else if / else 267 | // these extend if blocks 268 | 269 | // else if statements require another condition 270 | 271 | // else statements do not require a condition 272 | // true / false 273 | if(c > 5) { // c is greater than 5 c is equal to 5 or less than 5 274 | System.out.println(1); 275 | } else if(c < 5) { // c is less than 5 c is equal to 5 276 | System.out.println(2); 277 | } else { // c has to be 5 278 | System.out.println(3); 279 | } 280 | 281 | c = 10; 282 | 283 | if(c > 5) { 284 | System.out.println("big"); 285 | } 286 | //------------------------------- 287 | if(c < 5) { 288 | System.out.println("small"); 289 | } else { 290 | System.out.println("same"); 291 | } 292 | 293 | // else if 294 | // every prior else if/if statement have to be false 295 | // for java to even check the else if statement 296 | // you can have any number of else if statements 297 | // else 298 | // every prior else if/if statement have tobe false 299 | // you can only have one else statement 300 | 301 | int grade = 95; 302 | 303 | // our goal is to create an if block where 304 | // we print the appropriate letter grade for the corresponding 305 | // number grade 306 | 307 | // grade - 90+ "A" 308 | // grade - 80-89 "B" 309 | // grade - -79 "C" 310 | 311 | // Create an if block where it prints the appropriate letter 312 | // grade based on grade 313 | 314 | if(grade >= 90) { 315 | System.out.println("A"); 316 | } else if(grade >= 80) { 317 | System.out.println("B"); 318 | } else { 319 | System.out.println("C"); 320 | } 321 | } 322 | } 323 | -------------------------------------------------------------------------------- /2. Functions.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | // FUNCTIONS 4 | 5 | // 1. where do we make functions 6 | // 2. how do we call them 7 | 8 | //--------We will call functions here------ 9 | // A function will not do anything until you call it 10 | 11 | // use the name followed by the parenthesis 12 | // - within the parenthesis goes any values needed for 13 | // the parameters 14 | 15 | printName(); 16 | 17 | // functions are used to take repetitive chunks of 18 | // code and bind it to a single variable that we 19 | // can pass in different values to get different results 20 | 21 | returnName(); // THIS IS THE FUNCTION CALL 22 | // when something is return the function call 23 | // becomes whatever is returned 24 | 25 | String n = returnName(); 26 | System.out.println(returnName()); 27 | 28 | // A function call for a function that has parameters 29 | 30 | int sum = returnSum(5,6); 31 | System.out.println(sum); 32 | System.out.println(returnSum(10,20)); 33 | 34 | System.out.println(returnDouble(10)); 35 | System.out.println(returnDouble(4)); 36 | System.out.println(returnDouble(17)); 37 | 38 | System.out.println(returnRemainder(10,3)); 39 | System.out.println(returnRemainder(6,3)); 40 | System.out.println(returnRemainder(1,3)); 41 | 42 | System.out.println(returnBig(5, 6)); 43 | System.out.println(returnBig(10, 6)); 44 | } 45 | 46 | //-------Put functions here------- 47 | 48 | // Declaring a function 49 | 50 | // method header 51 | 52 | // visibility static return_type name(parameters) 53 | // - visiblity: accessibility of the function 54 | // - static: this defines a variable as belonging to the class 55 | // - return type: if it returns something, this will its data type 56 | // if it does not return, this will be void 57 | // - name: some unique name 58 | // - parameters: inputs that we define as variables 59 | 60 | static void printName() { 61 | System.out.println("David"); 62 | } 63 | 64 | // the return keyword 65 | 66 | // 1. it ends the function (MOST IMPORTANT) 67 | // 2. it gives back to the function call something 68 | 69 | // whenever you return something, the return type 70 | // has to match the data type of whatever you are returning 71 | static String returnName() { 72 | return "David"; 73 | // any code beyond this point is UNREACHABLE CODE 74 | } 75 | 76 | // we'll make a function that returns the sum of A and B 77 | // each parameter must be declared a data type 78 | // multiple parameters must be separated by commas 79 | static int returnSum(int A, int B) { 80 | return A + B; 81 | } 82 | 83 | // Create a function called returnDouble that takes 84 | // an integer parameter called a and returns DOUBLE its value 85 | 86 | static int returnDouble(int a) { 87 | return a * 2; 88 | } 89 | 90 | // Create a function called returnRemainder that takes two 91 | // integar parameters, a and b, and returns the modulus remainder 92 | // of a / b 93 | 94 | static int returnRemainder(int a, int b) { 95 | return a % b; 96 | } 97 | 98 | // Test them out with different inputs to make sure they work 99 | 100 | // Conditional return statements 101 | 102 | static int returnBig(int a, int b) { 103 | if(a > b) { 104 | return a; 105 | } else { 106 | return b; 107 | } 108 | } 109 | 110 | // As programmers, data types by themselves do not mean much 111 | 112 | // Its important that we give context to our data so that 113 | // we can utilize them better to find solutions 114 | 115 | // integers 116 | 117 | // its too hot if the temperature is above 90 degrees. 118 | // return true if the weather is too hot 119 | // return false if otherwise 120 | 121 | static boolean tooHot(int temp) { 122 | if(temp > 90) { 123 | return true; 124 | } else { 125 | return false; 126 | } 127 | } 128 | 129 | // booleans 130 | 131 | // booleans can only be true / false 132 | // - is or is not 133 | // - has or does not have 134 | // - yes or no 135 | 136 | // real context 137 | // - it is the weekend or it is not the weekend 138 | // - it is too hot or it is not too hot 139 | 140 | // if it is the weekend its relax time 141 | // if it is not the weekend, its study time 142 | 143 | // print relax time if we can relax 144 | // print study time if we cannot relax 145 | 146 | static void canWeRelax(boolean isWeekend) { 147 | if(isWeekend == true) { 148 | System.out.println("relax time"); 149 | } else { 150 | System.out.println("study time"); 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /3. Arrays.java: -------------------------------------------------------------------------------- 1 | import java.util.*; // this gives us access to the Arrays library 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | // 1. Variables 6 | // 2. If Statements 7 | // 3. Loops 8 | // 4. Data Structures 9 | 10 | // Data structures are basically big containers that store data at addresses 11 | 12 | // ARRAYS 13 | 14 | // An array stores values at indices (index) 15 | // - The values are ordered 16 | // - The size is static (you cannot add/remove values) 17 | // - The data type is static 18 | 19 | // Declaring an array 20 | 21 | // dataType[] name = new dataType[size] 22 | 23 | int[] nums = new int[5]; 24 | 25 | // default values 26 | // when arrays are declared this way... Java will provide default values for each of the values 27 | // int - 0 28 | // double - 0.0 29 | // boolean - false 30 | // String - null 31 | 32 | System.out.println(nums); // [I@76ed5528 33 | System.out.println(Arrays.toString(nums)); // [0, 0, 0, 0, 0] 34 | 35 | // [0, 0, 0, 0, 0] values 36 | // 0 1 2 3 4 indices 37 | 38 | // Indices will always start at 0 from the leftmost value 39 | // and increase by 1 until it reaches the rightmost value 40 | 41 | // Accessing values 42 | // name[index] - this will give us access to the value at that index 43 | 44 | System.out.println(nums[0]); 45 | 46 | // Changing values 47 | // we can use the same way we access values to change the values 48 | nums[0] = 5; 49 | 50 | System.out.println(Arrays.toString(nums)); 51 | 52 | // Exercise 53 | // Change the remaining 0s to values between 1-9 54 | 55 | nums[1] = 2; 56 | nums[2] = 4; 57 | nums[3] = 7; 58 | nums[4] = 6; 59 | 60 | System.out.println(Arrays.toString(nums)); 61 | 62 | int[] ar = { 9,2,8,4,3 }; 63 | 64 | System.out.println(Arrays.toString(ar)); 65 | 66 | nums = new int[] { 7,2,8,5,9 }; 67 | 68 | // length - there will be some variant of length for every data structure 69 | // this tells you the # of values in an array 70 | 71 | System.out.println(nums.length); 72 | 73 | // Most of the time we only care about two values as a programmer 74 | // The first and last values 75 | 76 | // How do we always get the first value? 77 | 78 | // What is the first index? 0 is always the first index 79 | // The first value is always name[0] 80 | 81 | // How do we always get the last value? 82 | 83 | // [7,2,8,5,9] length: 5 84 | // 0 1 2 3 4 85 | 86 | // [7,7,7] length: 3 87 | // 0 1 2 88 | 89 | // [1] length: 1 90 | // 0 91 | 92 | // The last index is always the length - 1 93 | // The last value is always name[name.length - 1] 94 | 95 | // There is one scenario where these are not always the case 96 | // That is when the array is empty 97 | 98 | // When an array empty... the length is 0 99 | 100 | // When you access an index that does not exist... you get an error 101 | // ArrayIndexOutOfBoundsException 102 | 103 | // System.out.println(nums[100]); 100 is not a valid index 104 | 105 | // The only valid indices are indices that are greater than equal to 0 and less than the length 106 | 107 | // Its easy to check what the length 108 | 109 | if(nums.length > 0) { 110 | System.out.println(nums[0]); 111 | System.out.println(nums[nums.length - 1]); 112 | } 113 | 114 | // Swapping values 115 | 116 | int a = 5; 117 | int b = 10; 118 | 119 | a = b; // a is assigned 10 120 | b = a; // b is assigned a which is 10 121 | 122 | // overall: we've lost 5 123 | 124 | a = 5; 125 | b = 10; 126 | 127 | int temp = a; 128 | a = b; 129 | b = temp; 130 | 131 | System.out.println(a); 132 | System.out.println(b); 133 | 134 | // Middle values 135 | 136 | // [9,2,8,4,3] length: 5 137 | // 0 1 2 3 4 138 | 139 | // [7,7,7] length: 3 140 | // 0 1 2 141 | 142 | // [1] length: 1 143 | // 0 144 | 145 | // This only applies to arrays of ODD length 146 | // length / 2 gives the middle index 147 | 148 | // [1,2,3,4,5,6] length: 6 149 | // 0 1 2 3 4 5 150 | 151 | // FOR EVEN length 152 | // length / 2 gives the rightmost middle index 153 | // length / 2 - 1 gives the leftmost middle index 154 | 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /4. Strings.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | // Strings are anything in quotation marks 4 | 5 | // "" is different from '' 6 | // ^ for Strings ^ for Characters 7 | 8 | String str = "hello"; 9 | 10 | // ["h","e","l","l","o"] 11 | // 0 1 2 3 4 12 | 13 | // We cannot retrieve,change values 14 | // the same way that we in an array 15 | 16 | // str[0] does not work 17 | // str[0] = "y" does not work 18 | 19 | // Strings are a functional data structure 20 | // - it requires functions to properly utilize 21 | 22 | // Strings are also IMMUTABLE (CANNOT CHANGE) 23 | // - we are only able to recreate Strings 24 | 25 | // .charAt(index) 26 | // - grabs an individual character at the specified 27 | // index of a String 28 | // Characters are numerical values represented 29 | // as letters 30 | // They can only be exactly one letter or space 31 | // or number or symbol 32 | 33 | System.out.println(str.charAt(0)); 34 | System.out.println(str.charAt(2)); 35 | 36 | // Characters can be compared using basic 37 | // relational operators 38 | // - remember when comparing characters 39 | // you have to use single quotes ' ' 40 | 41 | if(str.charAt(0) == 'h') { 42 | System.out.println("First letter is an h!"); 43 | } 44 | 45 | // Substring 46 | // .substring(startIndex, endingIndex) 47 | // .substring(startIndex) X 48 | 49 | // "hello" 50 | // 01234 51 | 52 | // I want to retrieve the "el" of "hello" 53 | 54 | // 1. figure out where it starts 55 | // - in this case, "e" is at index 1 56 | // 2. figure out where it ends 57 | // - in this case, "l" is at index 2 58 | // 3. add 1 to the last index 59 | // - the last index becomes 3, and not 2 60 | 61 | // startIndex: 1 62 | // endIndex: 3 63 | 64 | // startIndex in INCLUSIVE 65 | // endIndex is EXCLUSIVE 66 | 67 | System.out.println(str.substring(1,3)); // "el" 68 | 69 | // A substring is a STRING and not a Character 70 | // Substrings are represented by "" 71 | 72 | // We cannot compare Strings like we do with 73 | // Characters 74 | 75 | System.out.println("hi" == "hi"); // true 76 | 77 | System.out.println(str.substring(1,3) == "el"); // false 78 | 79 | // .equals(otherString) 80 | // this is how we properly compare Strings 81 | System.out.println(str.substring(1,3).equals("el")); 82 | 83 | // REFACTORING 84 | // using variables to simplify your code 85 | String ss = str.substring(1,3); 86 | System.out.println(ss.equals("el")); 87 | 88 | // .length() 89 | // tells you the number of letter in a String 90 | 91 | System.out.println(str.length()); 92 | 93 | // Strings do not have to be stored in variables 94 | // to utilize their functions 95 | 96 | System.out.println("hello".length()); 97 | System.out.println("".length()); // 0 98 | 99 | str = "Hello World"; 100 | // 012345678910 101 | 102 | // llo 103 | // str.substring(2,5); 104 | // o W 105 | // str.substring(4,7); 106 | // rld 107 | // str.substring(8,11); 108 | // World 109 | // str.substring(6,11); 110 | // Hello 111 | // str.substring(0,5); 112 | 113 | // As long as I know how long the substring is... 114 | // I can quickly identify the ending index by ADDING 115 | // the length of the substring to the starting index 116 | 117 | // How could find the proper String if I'm given a 118 | // variable that I have no idea what the String is 119 | 120 | int l = 3; 121 | 122 | // 1. identify the starting index 123 | // 2. add the length to the starting index 124 | 125 | System.out.println(str.substring(4, 4+l)); 126 | 127 | // I want to find if this String exists in the 128 | // BEGINNING 129 | 130 | // I want to see if "He" is in the beginning 131 | // of "Hello World" 132 | 133 | ss = "He"; 134 | 135 | System.out.println(str.substring(0, ss.length())); 136 | 137 | String rf = str.substring(0, ss.length()); 138 | 139 | if(str.substring(0, ss.length()).equals(ss)) { 140 | 141 | } 142 | 143 | if(rf.equals(ss)) { 144 | 145 | } 146 | 147 | // I want to see if this String exists in the END 148 | 149 | // I want to see if "rld" is in the end of 150 | // "Hello World" 151 | 152 | ss = "rld"; 153 | 154 | // How can we get 8 and 11 using ss.length() 155 | // and str.length()? 156 | 157 | // Hello World 158 | // 012345678910 159 | // str.length() - 11 160 | // ss.length() - 3 161 | 162 | // We can first get 11 by utilizing str.length() 163 | // We can get 8 by subtracting ss.length() from str.length() 164 | 165 | // startIndex: str.length() - ss.length() 166 | // endIndex: str.length() 167 | 168 | int len1 = str.length(); 169 | int len2 = ss.length(); 170 | rf = str.substring(len1 - len2, len1); 171 | System.out.println(rf.equals(ss)); 172 | 173 | // str.substring(str.length() - ss.length(), str.length()).equals(ss); 174 | 175 | // Whenever thinking about the first X letters of a String 176 | // generally speaking, it will be something like .substring(0,X); 177 | // X being the length of the substring 178 | 179 | // Whenever thinking about the last X letters of a String 180 | // generally speaking, it will be something like .substring(length - X, length) 181 | // X being the length of the substring 182 | // length being the length of the original String 183 | 184 | // Concatenation 185 | // adding strings together 186 | 187 | System.out.println("123" + "456"); 188 | 189 | // Anytime a NON String is added to a String... 190 | // it is converted into a String first 191 | 192 | System.out.println(123 + "456"); 193 | System.out.println("123" + 456); 194 | 195 | // Order of operations is still a thing 196 | 197 | System.out.println(1 + 2 + 3 + "456"); 198 | // 3 + 3 + "456" 199 | // 6 + "456" 200 | // "6" + "456" 201 | // "6456" 202 | System.out.println("123" + 4 + 5 + 6); 203 | // "123" + "4" + 5 + 6 204 | // "1234" + 5 + 6 205 | // "1234" + "5" + 6 206 | // "12345" + 6 207 | // "12345" + "6" 208 | // "123456" 209 | System.out.println("123" + (4 + 5 + 6)); 210 | 211 | // Variables and concatenation 212 | 213 | int a = 5; 214 | 215 | System.out.println("1234" + a); 216 | 217 | String name = "Jane"; 218 | 219 | System.out.println("Hi " + name + "!"); 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /5. Iteration.java: -------------------------------------------------------------------------------- 1 | public class Main { 2 | public static void main(String[] args) { 3 | // Iteration 4 | 5 | // Enhanced For Loop 6 | // this is a tool that lets us access each value of a data structure 7 | // by assigning each value of the data structure to a variable exactly once 8 | 9 | // [7,2,1,9,3] 10 | 11 | // val: 3 12 | 13 | // do something with val 14 | 15 | // structuring an enhanced for loop 16 | 17 | // for(_____________ : __________________________) 18 | // dataType name name of the data structure 19 | 20 | int[] ar = {7,2,1,9,3}; 21 | 22 | for(int v : ar) { 23 | System.out.println(v); 24 | } 25 | 26 | // What is iteration? 27 | 28 | // The act of accessing each piece of data in a data structure 29 | // and deriving some results from the data 30 | 31 | // iteration leads to algorithms 32 | 33 | // finding the sum of all the numbers 34 | 35 | // What are our limitations? 36 | 37 | // Enhanced for loop 38 | // - each value can only be accessed once 39 | // - you cannot change any of the values 40 | // - we do not have access to the index 41 | // - we have a hard time determining where exactly we are in the array 42 | 43 | // Imagine this context 44 | // - 5 unmarked doors 45 | // - behind each door is some random number 46 | // - you can have any # of sheets of paper, but you can only write 47 | // one piece of information on any sheet of paper 48 | // - you can update the information on the paper at anytime 49 | 50 | // Logic Limitations 51 | // - You have really bad memory 52 | // - as soon as I close a door, I've already forgotten what the number was 53 | // - You can only open each door once 54 | // - You can only have one door open at a time 55 | 56 | // Without using coding terms, I want you guys to write out how you 57 | // would find the sum of all the numbers behind the doors 58 | 59 | // 1. They use one sheet of paper and update the number on the paper 60 | // by adding the number behind the door to the number on the paper 61 | // 2. They use the same number of sheets of paper to mark down each 62 | // individual number on a separate sheet of paper 63 | 64 | // We use a single sheet of paper, we can have a 0 on the paper initially 65 | // Then as we open each door, one by one, we add to the number on our paper 66 | // whatever is behind the door 67 | // So... by the end, my piece of paper will have the sum 68 | 69 | // paper: tracking variable 70 | // doors: array 71 | // opening a door, one by one: iteration 72 | 73 | // Tracking variables will be initialized before the loop itself 74 | 75 | // before we've opened the first door 76 | int sum = 0; 77 | // the process of opening each door 78 | for(int val : ar) { 79 | // the code inside here is what you do when you open a door 80 | // and see the value 81 | sum += val; 82 | } 83 | // after we've closed the last door 84 | System.out.println(sum); 85 | 86 | // Counting 87 | // Count the number of even values behind the doors 88 | 89 | // We use a piece of paper initially with 0 on it 90 | // then go to each door and check if the number is even, 91 | // if it is you increase the number on the paper by 1 92 | 93 | int cnt = 0; 94 | for(int val : ar) { 95 | if(val % 2 == 0) { 96 | cnt++; 97 | } 98 | } 99 | System.out.println(cnt); 100 | 101 | // Finding the LARGEST value in the array 102 | 103 | // our piece of paper will have 0 on it initially, 104 | // we go to each door and check if the number behind the door 105 | // is greater than the number on our paper... 106 | // if it is, you change the number on the paper to the number 107 | // behind the door 108 | 109 | int max = Integer.MIN_VALUE; 110 | for(int val : ar) { 111 | if(val > max) { 112 | max = val; 113 | } 114 | } 115 | 116 | System.out.println(max); 117 | 118 | // Try to find the minimum value in the array 119 | 120 | int min = Integer.MAX_VALUE; 121 | 122 | for(int val : ar) { 123 | if(val < min) { 124 | min = val; 125 | } 126 | } 127 | 128 | System.out.println(min); 129 | 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /6. Indexed Iteration.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | // Loops 4 | // These building blocks are used to 5 | // repeat things 6 | 7 | // Repeating if statement 8 | // - it will continue to repeat 9 | // while the condition is true 10 | 11 | // 3 Components 12 | // Start 13 | // End 14 | // Change 15 | 16 | // The change is responsible for 17 | // getting your starting state to 18 | // the ending state 19 | 20 | // a is my state 21 | // int a = 0; // start 22 | 23 | // I want to keep looping until 24 | // a reaches 5 25 | 26 | // while(a < 5) { // end 27 | // System.out.println(a); 28 | // a++; // change 29 | // } 30 | 31 | // System.out.println(a); 32 | 33 | // Treat for loops logically 34 | // the same way as a while loop 35 | 36 | // for(start; end; change) {} 37 | 38 | // for(int i = 0; i < 5; i++) { 39 | // System.out.println(i); 40 | // } 41 | 42 | // For loops variable/state 43 | // will generally not be accessible 44 | // outside of the loop 45 | 46 | // for(int i = 0; i < 5; i++) { 47 | // System.out.println(i); 48 | // } 49 | 50 | // 1 <-- start 51 | // 2 52 | // 3 53 | // 4 54 | // 5 <-- end 55 | 56 | // for(int i = 1; i < 6; i++) { 57 | // System.out.println(i); 58 | // } 59 | 60 | // 10 <-- start 61 | // 9 62 | // 8 63 | // 7 64 | // 6 <-- end 65 | 66 | // for(int i = 10; i > 5; i--) { 67 | // System.out.println(i); 68 | // } 69 | 70 | // 3 <-- start 71 | // 6 72 | // 9 73 | // 12 74 | // 15 <-- end 75 | 76 | // for(int i = 3; i < 16; i += 3) { 77 | // System.out.println(i); 78 | // } 79 | 80 | // 1) 81 | 82 | // 2 83 | // 4 84 | // 6 85 | // 8 86 | // 10 87 | 88 | // for(int i = 2; i < 11; i += 2) { 89 | // System.out.println(i); 90 | // } 91 | 92 | // 2) 93 | 94 | // 10 95 | // 20 96 | // 30 97 | // 40 98 | // 50 99 | 100 | // for(int i = 10; i < 51; i += 10) { 101 | // System.out.println(i); 102 | // } 103 | 104 | // 3) 105 | 106 | // 1 107 | // 2 108 | // 4 109 | // 8 110 | // 16 111 | 112 | // for(int i = 1; i < 17; i += i) { 113 | // System.out.println(i); 114 | // } 115 | 116 | // Conditions with loops 117 | 118 | // 1 119 | // EVEN 120 | // 3 121 | // EVEN 122 | // 5 123 | 124 | // for(int i = 1; i < 6; i++) { 125 | // if(i % 2 == 0) { 126 | // System.out.println("EVEN"); 127 | // } else { 128 | // System.out.println(i); 129 | // } 130 | // } 131 | 132 | // 1 133 | // 2 134 | // THREE 135 | // 4 136 | // 5 137 | // THREE 138 | // 7 139 | // 8 140 | // THREE 141 | // 10 142 | // for(int i = 1; i < 11; i++) { 143 | // if(i % 3 == 0) { 144 | // System.out.println("THREE"); 145 | // } else { 146 | // System.out.println(i); 147 | // } 148 | // } 149 | 150 | // 1 151 | // 2 152 | // THREE 153 | // 4 154 | // FIVE 155 | // THREE 156 | // 7 157 | // 8 158 | // THREE 159 | // FIVE 160 | // 11 161 | // THREE 162 | // 13 163 | // 14 164 | // THREEFIVE 165 | 166 | // for(int i = 1; i < 16; i++) { 167 | // if(i % 3 == 0 && i % 5 == 0) { 168 | // System.out.println("THREEFIVE"); 169 | // } else if(i % 3 == 0) { 170 | // System.out.println("THREE"); 171 | // } else if(i % 5 == 0) { 172 | // System.out.println("FIVE"); 173 | // } else { 174 | // System.out.println(i); 175 | // } 176 | // } 177 | 178 | 179 | // Indexed Iteration 180 | 181 | int[] ar = {9,2,8,4,3}; 182 | // 0 1 2 3 4 183 | 184 | // i in the for loop stands for index 185 | 186 | // our loop will use its state to 187 | // access each INDEX of the array 188 | 189 | // for(int i = 0; i < 5; i++) { 190 | // System.out.println(i); 191 | // System.out.println(ar[i]); 192 | // System.out.println(); 193 | // } 194 | 195 | // for(int val : ar) { 196 | // System.out.println(val); 197 | // } 198 | 199 | // i ar[i] 200 | // 0 -> ar[0] 201 | // 1 -> ar[1] 202 | // 2 -> ar[2] 203 | // 3 -> ar[3] 204 | // 4 -> ar[4] 205 | 206 | int[] nums = {3,4,7}; 207 | // 0 1 2 208 | // for(int i = 0; i < 3; i++) { 209 | // System.out.println(nums[i]); 210 | // } 211 | 212 | // We can use the length of the array 213 | // to figure out the ending state 214 | // of our loops 215 | 216 | // for(int i = 0; i < nums.length; i++) { 217 | // System.out.println(nums[i]); 218 | // } 219 | 220 | // for(int i = 0; i < nums.length; i++) { 221 | // nums[i] = nums[i] * 2; 222 | // } 223 | 224 | // for(int val : nums) { 225 | // System.out.println(val); 226 | // } 227 | 228 | // 1. Counting 229 | // 2. Sum 230 | // 3. Max/Min 231 | 232 | // 1) Count the number of values 233 | // in ar that are greater than 4 234 | // and then print the count 235 | // 2) Find the sum of all the values 236 | // and then print the sum 237 | // 3) Find the max and min of ar 238 | // and print them 239 | 240 | // name[i] -> value 241 | // i -> index 242 | 243 | int cnt = 0; 244 | for(int i = 0; i < ar.length; i++) { 245 | if(ar[i] > 4) { 246 | cnt++; 247 | } 248 | } 249 | System.out.println(cnt); 250 | 251 | int sum = 0; 252 | for(int i = 0; i < ar.length; i++) { 253 | sum += ar[i]; 254 | } 255 | System.out.println(sum); 256 | 257 | int max = Integer.MIN_VALUE; 258 | int min = Integer.MAX_VALUE; 259 | for(int i = 0; i < ar.length; i++) { 260 | if(ar[i] > max) { 261 | max = ar[i]; 262 | } 263 | if(ar[i] < min) { 264 | min = ar[i]; 265 | } 266 | } 267 | 268 | System.out.println(max); 269 | System.out.println(min); 270 | } 271 | } 272 | -------------------------------------------------------------------------------- /7. Neighboring Indices.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | // Neighboring Indices 4 | 5 | // checking the immediate neighbors 6 | // when visiting a value 7 | 8 | // [9,2,8,4,3] 9 | // - - ^ - - 10 | 11 | // Count the number of times 2 appears 12 | // immediately after a 1 13 | 14 | int cnt = 0; 15 | int[] ar = {9,1,2,2,1,3,1,2,1}; 16 | // i i+1 17 | 18 | // ar[i] - value 19 | // ar[i+1] - value immediately after 20 | 21 | for(int i = 0; i < ar.length - 1; i++) { 22 | if(ar[i] == 1 && ar[i+1] == 2) { 23 | cnt++; 24 | } 25 | } 26 | 27 | // System.out.println(cnt); 28 | 29 | // Array index out of bounds exception 30 | // is very common with neighboring indices 31 | 32 | // print out the pairs of numbers 33 | 34 | // for(int i = 0; i < ar.length - 1; i++) { 35 | // System.out.println(ar[i]); 36 | // System.out.println(ar[i+1]); 37 | // System.out.println(); 38 | // } 39 | 40 | // If I go forward some N amount of spaces, 41 | // I have to reduce my length by the same N amount 42 | // i, i+N 43 | 44 | // [1,2,3,4,5,6,7,8,9] length: 9 45 | // 0 1 2 3 4 5 6 7 8 46 | // i i+2 47 | 48 | // for(int i = 0; i < ar.length - 2; i++) 49 | 50 | // If I go backward some M amount of spaces, 51 | // I have to increase my start by the same M amount 52 | // i, i-M 53 | 54 | // [1,2,3,4,5,6,7,8,9] length: 9 55 | // 0 1 2 3 4 5 6 7 8 56 | // i-1 i 57 | 58 | // for(int i = 1; i < ar.length; i++) 59 | 60 | // for(int i = M; i < ar.length - N; i++) { 61 | // this range accomodates for i,i+N 62 | // and also accomodates for i,i-M 63 | // } 64 | 65 | // lets print every triplet in the array 66 | int[] nums = {9,2,8,4,3}; 67 | // i 68 | // 9 2 8 69 | // 2 8 4 70 | // 8 4 3 71 | 72 | // i-1 i i+1 73 | // -1 0 1 X 74 | // 0 1 2 75 | // 1 2 3 76 | // 2 3 4 77 | // 3 4 5 X 78 | 79 | // for(int i = 1; i < nums.length - 1; i++) { 80 | // System.out.println(nums[i-1]); 81 | // System.out.println(nums[i]); 82 | // System.out.println(nums[i+1]); 83 | // System.out.println(); 84 | // } 85 | 86 | for(int i = 0; i < nums.length - 2; i++) { 87 | System.out.println(nums[i]); 88 | System.out.println(nums[i+1]); 89 | System.out.println(nums[i+2]); 90 | } 91 | 92 | // if you have multiple i+__ or i+__, take the LARGEST 93 | 94 | // Short Circuiting 95 | 96 | // && - if any of them are false, the whole thing is false 97 | // || - if any of them are true, the whole thing is true 98 | 99 | // if(false && |____) { 100 | 101 | // } 102 | 103 | // if(true || |____) { 104 | 105 | // } 106 | 107 | int[] arr = {9,2,8,4,3}; 108 | 109 | for(int i = 0; i < arr.length; i++) { 110 | if(i < arr.length - 1 && arr[i] == 2 && arr[i+1] == 2) { 111 | 112 | } 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /8. Cloning.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | class Main { 4 | public static void main(String[] args) { 5 | int[] ar = {9,2,8,4,3}; 6 | 7 | // Arrays.toString(arrayName) 8 | // to get a String version of the array 9 | System.out.println(Arrays.toString(ar)); 10 | 11 | // Making a copy or a variant 12 | // of an existing array without 13 | // changing the existing values of the 14 | // original 15 | 16 | // 1. figuring out the length of the 17 | // cloned array 18 | // 2. figuring out how the indices 19 | // line up 20 | 21 | // 9 2 8 3 4 22 | // 0 1 2 3 4 23 | 24 | // 2 8 4 25 | // 0 1 2 26 | 27 | // Generate a clone that is the original 28 | // with its values doubled 29 | // 9 2 8 4 3 => 18 4 16 8 6 30 | // 0 1 2 3 4 0 1 2 3 4 31 | 32 | // the clones length may be based off 33 | // of the length of the original 34 | int[] clone = new int[ar.length]; 35 | for(int i = 0; i < ar.length; i++) { 36 | clone[i] = ar[i] * 2; 37 | } 38 | System.out.println(Arrays.toString(clone)); 39 | 40 | // I want to generate a new array consisting 41 | // of only the even numbers 42 | 43 | // 1. figure out how many even numbers there are 44 | 45 | // given ar, count the number of even values 46 | // in the array 47 | 48 | int cnt = 0; 49 | for(int i = 0; i < ar.length; i++) { 50 | if(ar[i] % 2 == 0) { 51 | cnt++; 52 | } 53 | } 54 | System.out.println(cnt); 55 | 56 | int[] evens = new int[cnt]; 57 | 58 | // 9 2 8 3 4 59 | // 0 1 2 3 4 60 | 61 | // _ _ _ 62 | // 0 1 2 63 | 64 | // create a variable to track the index 65 | // that you are on in the clone 66 | 67 | int index = 0; 68 | for(int i = 0; i < ar.length; i++) { 69 | if(ar[i] % 2 == 0) { 70 | evens[index] = ar[i]; 71 | index++; 72 | } 73 | } 74 | System.out.println(Arrays.toString(evens)); 75 | 76 | 77 | int[] nums = {1,2,3,4,1,2,3,1,2,1}; 78 | 79 | // Given nums, generate a new array 80 | // consisting of the values that 81 | // are odd. 82 | 83 | cnt = 0; 84 | for(int i = 0; i < nums.length; i++) { 85 | if(nums[i] % 2 != 0) { 86 | cnt++; 87 | } 88 | } 89 | 90 | int[] odds = new int[cnt]; 91 | 92 | index = 0; 93 | for(int i = 0; i < nums.length; i++) { 94 | if(nums[i] % 2 != 0) { 95 | odds[index] = nums[i]; 96 | index++; 97 | } 98 | } 99 | System.out.println(Arrays.toString(odds)); 100 | 101 | // Reverse the order of the numbers 102 | // [9,2,8,4,3] -> [3,4,8,2,9] 103 | // 0 1 2 3 4 0 1 2 3 4 104 | 105 | // i length - 1 - i 106 | // 0 -> 4 107 | // 1 -> 3 108 | // 2 -> 2 109 | // 3 -> 1 110 | // 4 -> 0 111 | 112 | int[] reversed = new int[ar.length]; 113 | 114 | for(int i = 0; i < ar.length; i++) { 115 | reversed[reversed.length - 1 - i] = ar[i]; 116 | } 117 | 118 | System.out.println(Arrays.toString(reversed)); 119 | 120 | // When it comes to patterns... it's usually 121 | // some form of utilizing the length and the index 122 | 123 | // other relevant variables can also be considered 124 | 125 | // shift all the values left once 126 | // [9,2,8,4,3] -> [2,8,4,3,9] 127 | // 0 1 2 3 4 0 1 2 3 4 128 | 129 | // 0 -> 4 130 | // i i-1 131 | // 1 -> 0 132 | // 2 -> 1 133 | // 3 -> 2 134 | // 4 -> 3 135 | 136 | // do the pattern first, then the outlier separately 137 | 138 | int[] left = new int[ar.length]; 139 | 140 | for(int i = 1; i < ar.length; i++) { 141 | left[i-1] = ar[i]; 142 | } 143 | 144 | left[left.length - 1] = ar[0]; 145 | 146 | System.out.println(Arrays.toString(left)); 147 | 148 | // generating an array off of not an array 149 | 150 | // range a-b 151 | 152 | // int a = 1; 153 | // int b = 10; 154 | 155 | // generate an array consisting of all the 156 | // values between a (inclusive) and b (exclusive) 157 | 158 | // 1,10 => [1,2,3,4,5,6,7,8,9] 159 | // 0 1 2 3 4 5 6 7 8 160 | index = 0; 161 | int[] arr = new int[b - a]; 162 | for(int i = a; i < b; i++ ) { 163 | arr[index] = i; 164 | index++; 165 | } 166 | System.out.println(Arrays.toString(arr)); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /9. Review.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | // 1. Structure 4 | // 2. Application 5 | 6 | // Iteration 7 | // Enhanced vs Indexed 8 | 9 | int[] ar = {9,2,8,4,3}; 10 | 11 | // Enhanced 12 | // for(dataType name : dataStructureName) { 13 | 14 | // } 15 | 16 | for(int val : ar) { 17 | System.out.println(val); 18 | } 19 | 20 | // Pros 21 | // - easier to write <------ only this for now 22 | // - later on this will be used to access 23 | // data in more complex data structures 24 | 25 | // Cons 26 | // - You have no access to the index 27 | // - you can't change values 28 | // - you don't know where you are in the array 29 | // - cannot skip values 30 | // - cannot check neighbors 31 | 32 | // It's used only when you need to check 33 | // each individual value once. 34 | 35 | // ex. countEvens 36 | // ex. bigDiff 37 | // ex. centeredAverage 38 | // ex. sum28 39 | 40 | // 1. Count the even numbers - YES 41 | 42 | // int cnt = 0; 43 | // for(int val : ar) { 44 | // if(val % 2 == 0) { 45 | // cnt++; 46 | // } 47 | // } 48 | // System.out.println(cnt); 49 | 50 | // 2. Change every instance of 5 to 15 - NO 51 | // ^ 52 | 53 | // 3. See if there is a 2 next to a 2 - YES/(NO) 54 | // boolean seen2 = false; 55 | // for(int val : ar) { 56 | // if(seen2 == true && val == 2) { 57 | // // YES 58 | // } else if(seen2 == true) { 59 | // seen2 = false; 60 | // } else if(val == 2) { 61 | // seen2 = true; 62 | // } 63 | // } 64 | 65 | // for(int i = 0; i < ar.length; i++) { 66 | // if(ar[i] == 2 && ar[i+1] == 2) { 67 | // YES 68 | // } 69 | // } 70 | 71 | // Indexed For Loops 72 | 73 | // Con 74 | // - it takes longer to write 75 | // - later on, this loop cannot access 76 | // the values in certain data structures 77 | 78 | // Pros 79 | // - does everything the enhanced loop does 80 | // without the cons 81 | 82 | 83 | // Neighboring Indices 84 | // - this requires the indexed for loop 85 | 86 | // if I am checking forward some N indices 87 | // ex. ar[i] and ar[i+N] 88 | // then I have to reduce the length by N 89 | 90 | // for(int i = 0; i < ar.length - N; i++) 91 | 92 | // [1,2,3,4,5] 93 | // [i i+2] 94 | 95 | // if I am checking backward some N indices 96 | // ex. ar[i] and ar[i-N] 97 | // then I increase the start by N 98 | 99 | // for(int i = 0 + N; i < ar.length; i++) 100 | 101 | // [1,2,3,4,5] 102 | // [i-2 i] 103 | 104 | // Short Circuiting 105 | // Abusing && and || 106 | 107 | // Languages try to be efficient 108 | // _____ && ______ 109 | // ^ ^ 110 | // false skipped 111 | 112 | // _____ || ______ 113 | // ^ ^ 114 | // true skipped 115 | 116 | // for(int i = 0; i < ar.length; i++) 117 | 118 | // if(i < ar.length - i && ar[i] == ar[i+1]) 119 | 120 | // if(i >= ar.length - 1 || ar[i] == ar[i+1]) 121 | 122 | // When to use short circuiting 123 | // - if it requires to check every value with i 124 | // - you have situations where you check 125 | // different sets of neighboring indices 126 | // - if(ar[i] == ar[i+1]) 127 | // - if(ar[i] == ar[i+2]) 128 | 129 | // 9 2 8 4 3 130 | // [ ] 131 | // [ ] 132 | 133 | // ex. has77 134 | // ex. twoTwo 135 | 136 | 137 | // When you don't have to 138 | // - if it does NOT require you to check every 139 | // value with i 140 | 141 | // ex. has22 142 | // ex. matchUp 143 | // ex. modThree 144 | // ex. haveThree 145 | 146 | // Cloning / Patterns 147 | 148 | // 1. figure out the length of the clone 149 | // 2. figure out if you need to establish 150 | // a pattern or use a variable to track 151 | // the position in the clone 152 | 153 | // figuring out the length 154 | // 1. counting something 155 | // ex. evenOdd or warmup questions 156 | // 2. finding the rest before/after 157 | // a certain position 158 | // ex. pre4, post4 159 | 160 | // pattern 161 | // ex. shiftLeft 162 | // [1,2,3,4,5] -> [2,3,4,5,1] 163 | // i -> i+1 164 | // 0 -> 1 165 | // 1 -> 2 166 | // 2 -> 3 167 | // 3 -> 4 168 | // 4 -> 0 X 169 | 170 | // int[] nums = {1,2,3,4,5}; 171 | 172 | // int[] clone = new int[nums.length]; 173 | 174 | // for(int i = 0; i < ar.length - 1; i++) { 175 | // clone[i] = ar[i+1]; 176 | // } 177 | // clone[clone.length - 1] = ar[0]; 178 | 179 | // for(int i = 0; i < ar.length; i++) { 180 | // clone[i] = ar[(i+1) % ar.length]; 181 | // } 182 | 183 | // [9,2,8,4,3] 184 | // i i+1 185 | // i -> (i+1) % len 186 | 187 | // further with patterns (outside of cloning) 188 | // - patterns generally utilize the index (i), 189 | // the length (___.length) and any other 190 | // relevant variables pertinent to the question 191 | 192 | // ex. sameEnds 193 | 194 | // Strategies for iterative questions 195 | 196 | // WRITE ON PAPER THE ARRAY 197 | 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Justin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java-Comprehensive-Review 2 | 3 | The basics of Java condensed into nine lessons, embodied in nine files, in one GitHub repository. This is an useful review in preparation for AP Compsci A, as its associated projects will have to be completed in the Java programming language. 4 | --------------------------------------------------------------------------------