Monthly Archives: April 2023

DATA TYPE AND VARIABLES IN JAVA

DATA TYPE A Data Type is a classification that precisely specifies a homogeneous set of values and the operations that can be applied to these values. For example, if we take integers as the Data Type, that is, the set of those numbers that do not have a decimal part, the operations we can perform on this set of values are arithmetic operations. Although Java is an Object-Oriented programming language, it is critical to understand that not all values we can express in Java are realized as objects. PRIMITIVE TYPES AND REFERENCE TYPES Primitive types are [...]

By |2023-04-02T23:00:24+00:00April 2, 2023|0 Comments

THE BYTECODE AND THE JAVA VIRTUAL MACHINE

THE BYTECODE Bytecode is the product of the compilation phase in Java. The JVM is a virtual, software-described representation of a real computer. The JVM has a machine instruction set, like a regular CPU. The instruction set recognized by the JVM is called Bytecode. There are 256 instructions in the Java Virtual Machine in all, and each of these instructions occupies one byte. Hence the name Bytecode. Compiling a Java source using the Javac command produces a file with a .class extension that contains the Bytecode. To touch on what Bytecode actually looks like let's create [...]

By |2023-04-06T20:37:16+00:00April 6, 2023|0 Comments

OPERATORS IN JAVA FIRST PART

OPERATORS IN JAVA An operator is a specific symbol in a programming language that allows a specific operation to be performed. An operator always acts on a set of elements called operands. In the example you can see the operator + which acts on two operands. As we shall see, it is possible to join several operators together; in these cases, precedence must be established among the operators. Precedence is a rule that some operators have priority over others. Then when we are in compound operations in which the operators have the same precedence associativity comes [...]

By |2023-04-11T18:54:11+00:00April 11, 2023|0 Comments

OPERATORS IN JAVA SECOND PART

OPERATORS IN JAVA THE COMPOUND ASSIGNMENT OPERATORS Let's start right away with an example. From the figure below you can see that we took the value of the variable x (10) we added 5 and assigned the result to the variable x. We see the contracted form alongside that has the same meaning. x+=5 -> x = x + 5 Compound assignment forms exist for all arithmetic operators: +=;-=;*=;/=;%= The use of these forms is very common in Java, so it is good to understand them early on. THE [...]

By |2023-04-13T22:52:34+00:00April 13, 2023|0 Comments

OPERATORS IN JAVA THIRD PARTY

THE CONDITIONAL OPERATOR Later in the course we will learn how to use conditional tests, that is, instructions that allow us to execute different blocks of code depending or not on the occurrence of certain conditions. The conditional operator although in a limited form enables us to achieve the same purpose. It is a ternary operator, that is, it uses three operands. exp1 is a boolean expression. If the expression exp1 returns true then the second expression is executed, otherwise if false exp3. Let's take an example. EXAMPLE TERNARY OPERATOR In the [...]

By |2023-04-15T08:58:31+00:00April 15, 2023|0 Comments

FLOW CONTROL IN JAVA FIRST PART

FLOW CONTROL INTRODUCTION Based on what we have learned so far, we know that the execution of a Java program occurs sequentially. In any software we are going to write there is a need to alter the normal flow of the program based on a number of conditions that occur. In this regard Java like all other programming languages provides us with some flow control instructions. A program always has its own execution path as we see in the figure. This is the simplest case, the program executes instructions one after the other in a top-down sequence, [...]

By |2023-04-18T23:17:07+00:00April 18, 2023|0 Comments

FLOW CONTROL IN JAVA SECOND PART

THE WHILE CYCLE Having examined conditional tests we will now go on to look at the flow control structures that belong to iterations. The image shows the general form of the while loop. The while loop repeats a series of lines of code until the condition specified in parentheses is true. The condition is evaluated immediately, that is, before the cycle starts. This has an important implication because if the first time the Boolean expression is evaluated it is false, the entire loop is not executed. The post increment instruction x++ is the one that allows [...]

By |2023-04-20T21:12:44+00:00April 20, 2023|0 Comments

CLASSES IN JAVA FIRST PART

CLASSES IN JAVA DEFINITION A class is the definition of an object type. A class specifies the name and type of object instance variables, but does not specify their value. A class specifies the methods of its objects. An object of a class is an instance of the class. Let us start with an example that consists of defining an ContoCorrente class. As you see in the figure such a class has a balance variable(attribute) which, as we shall see later, is of type private and three public methods. In the rightmost part you can see three instances of [...]

By |2023-04-30T07:17:15+00:00April 29, 2023|0 Comments
Go to Top