In Java, there are primitive and non-primitive data types. Some primitive data types include int, double and boolean, and some non-primitive data types include String and array.
"static" or "hard coded" programs typically when all of the website information is displayed by default. There are no instances of user input in these types of programs.
To increase user interaction, having user inputs is important
In Java, Scanner is the utility class used for console user input
All programming has the means of formatting and combining data. An example of this is shown through concatenation (e.g. "Hello," + " World!" = "Hello, World!". The "+" symbol combined the two strings).
The relationship between a class and an object is that a class is essentially a template for an object, and an object is an instance of a class.
Some Java imports are designated toward allowing user input and console output in the terminal.
The Scanner class makes an object to collect inputs / menu selections from users
The System class can be used to call static methods like System.out.print() and System.out.println() to output in the console.
The Math class can be used to call the static method Math.random() to generate a random number within a specified range.
Objects are often intended to encapsulate Frontend, Backend, Web Site control flow, Database CRUD Operations, and many more.
With Swing and AWT imports, Java has the ability to provide a Graphical User Interface (GUI) on the desktop.
A Boolean expression is a logical statement that can evaluate to only two values, which are usually true or false.
A Boolean expression may comprise of a combination of Boolean constants true or false.
An if else statement is a type of conditional statement that performs a specific action if it evaluates to true, and performs another specific action if it evaluates to false
An if else code block can involve the if(), else if(), and else statements.
A switch statement is similar to an if else statement, as it has an initial controlling expression and has a specific action designated for each case value, in which if the controlling expression matches the conditions of a case, the action for that case will be performed.
The De Morgan's Law basically uses the logical operators or, and, nor, and nand. For two conditions paired with an ||(or) operator, the program will evaluate to true if at least one of the conditions evaluates to true. For two conditions paired with an &&(and) operator, the program will only evaluate to true only if both of the conditions evaluate to true. For two conditions paired with a !(not) operator, the program is reversed, as it will print true if the condition evaluates to false, and print false if the condition evaluates to true.
Iteration can include creating a loop to perform an action until a specified condition(s) is/are met.
Iteration can be used in standard arithmetic-based and String algorithms.
for and while loops are used in code to represent iterative processes.
Nesting loop and iteration statements basically involve having a loop integrated inside another loop. For example, consider an outside for loop that repeats 3 times and an inside for loop that repeats 7 times. For each iteration in the outside for loop, the inside for loop will iterate 7 times. This will result in the program iterating a total of 21 times.
A recursion loop, like the while loop and for loop, repeats itself over and over again until a certain condition is met. The uniqueness of recursion loops come from the fact that they involve a function calling itself to repeat a task.
The anatomy of an object typically consists of state, attributes, and behavior. An object is practically an instance of a class.
A class defines an abstract data type. Object references can be done with String variables, while instance variables contain attributes, behaviors, and data for objects.
Methods are behaviors or actions that can be done with objects, and constructors create the object itself.
The main method tests a class and contains instance variables which include attributes, fields, and properties.
Constructors are a special method for object instantiation in that is sets initial values for variables and can run methods.
A default constructor has no arguments and is used when no constructor is defined. A class can have multiple constructors.
In Java, arrays and ArrayLists are different data structures.
Java arrays can have primitive (e.g. int, char, float) or referenced (e.g. String, Array, classes) data types.
int[] array = new int[10]; creates an array with 10 elements with type into and value 0.
int[] array2 = {10, 9, 8, 7, 6}; is an example way of initializing an array.