Curso Propedéutico Programación Dr. Abraham Rodríguez Mota
Java Programming Language II
Classes and objects (Review) An object's instance variables (data) are packaged, or encapsulated, within the object. The instance variables are surrounded by the object's methods. With certain well-defined exceptions, the object's methods are the only means by which other objects can access or alter its instance variables. In Java, classes can declare their instance variables to be public, in which cases the instance variables are globally accessible to other objects.
A class is a software construct that defines the data (state) and methods (behavior) of the specific concrete objects that are subsequently constructed from that class. In Java terminology, a class is built out of members, which are either fields or methods . Fields are the data for the class. Methods are the sequences of statements that operate on the data. Fields are normally specific to an object--that is, every object constructed from the class definition will have its own copy of the field. Such fields are known as instance variables. Similarly, methods are also normally declared to operate on the instance variables of the class, and are thus known as instance methods . A class class in and of itself is not an object. object. A class is like a blueprint blueprint that defines defines how an object will look look and behave when when the object is created or instantiated from the specification declared by the class. You obtain concrete objects by instantiating a previously defined class.
Source:https://pokemon.fandom.co Source:https://p okemon.fandom.com/wiki/Generation m/wiki/Generation_I _I
Operators •
The Java programming language has around 30 operators
Operators •
The Java programming language has around 30 operators
Assigning numbers int x = 10; float y = 3.5f;
int p; p = 9; float z = 10.3f, r, w;
Assigning objects references references String message = “Hello World”; File csv = new File(“test.csv”);
Arithmetic Operators •
This are used to perform mathematic calculations calculations
Arithmetic Operators
Arithmetic Operators
Unary Operators This operators involve in a single operand operand
Unary Operators
Unary Operators Note that the increment and decrement operators can be placed before (prefix) or after (postfix) the operand, e.g. ++x or x++, --y or y--. When using these two forms in an expression, the difference is: ! !
Prefix form: the operand is incremented or decremented before used in the expression. Postfix form: the operand is incremented or decremented after used in the expression.
Relational Operators These operators are used to compare two operands or two expressions and result is a boolean.
Conditional Operators These operators are used to perform conditional-AN conditional-AND D and conditional-OR operations on two boolean expressions and result in a boleta value. They have “short-circuiting” behavior: ! !
For the && operator: if the left expression is evaluated to false, then the right expression is not evaluated. Final result is false. For the || operator: if the left expression is evaluated to true, then the right expression is not evaluated. Final result is true.
Conditional Operators Other conditional operators are ? and : which form a ternary (three operands) in the following form: result = A ? B : C
This is interpreted like this: if A evaluates to true, then evaluates B and assign its value to the result. Otherwise, if A evaluates to false, then evaluates C and assign its value to the result. For short, we can say: If A then B else C . So this is also referred as shorthand for an if-then-else statement.
Type comparis comparison on Operat Operator or (instanceof) The instanceof operator tests if an object is an instance of a class, a subclass or a class that implements an interface; and result in a boolean bo olean value.
Bitewise and Bit shift Operators These operators perform bitwise and bit shift operations on only integral types, not float types. They are rarely used so the listing here is just for reference:
According to Java Language Specification, the integral types defined in Java are byte byte,, short , int , long long,, and char . The values of byte byte,, short , int , and long long are signed two's-complement integers, but the values of char are 16-bit unsigned integers which represents UTF-16 code units.
Bitwise and Bit shift Operators
References https://www.codejava.net/java-core/the-java-language/summary-of-operators-in-java-with-examples