Use constants rather than numbers - declaring variables with FINAL statement


Suppose the government hired you to create an application that, among other things, examines whether a citizen is adulthood or not.
How would you do this conditional test?

if (age> = 21) or who knows ... if (age > 20)?

Both correct, but absolutely not recommended.
In this article we will teach an important lesson in Java: Do not use numbers, but constant.

Java Video Lesson: Constructors


This video is from the New Boston project: http://thenewboston.org/ , made by Bucky Roberts.
We just find the best Java video lesson for your.

In this video tutorial, Buckey will teach us more about the constructors methods in Java.

Java Video Lesson - Composition

This video is from the New Boston project: http://thenewboston.org/ , made by Bucky Roberts.
We just find the best Java video lesson for your.

In this video tutorial, Buckey will teach us more about the Composition technique in Java.
We already explained about Composition in Composition: exchanging information between objects

Composition: exchanging information between objects

One of the best tricks of Java programming language is the communication between its elements, variables, methods, objects, classes, and things we will see later. More than that, what's great is that we can control that communication, it can be: public, private and protected. 

In this tutorial, we will start this communication, talking about the Composition, which is simply the act of passing an object to another, to use its methods or attributes. 

Application: Simulation simple bank account

Application: Bank account / ATM simple Java 

Create a prototype of an ATM in Java programming language. Earlier, it asks your name and initial value in the account. The program must provide a 4-digit number - account number - to the user (use Random). These data will be used to create an object of class "ATM.java" 

Then, shows a menu with options (this menu should be a method): 
- Bank Statementt: displays the name, account number, balance, and how many operations have been performed 
- Withdraw: get the amount to be withdrawn, reports can be drawn up (can not be negative) and shows the balance 
- Deposit: receives the amount to be deposited and shows the new balance 
- Exit 

This menu appears until the user chooses to exit. The other options are methods that should be part of the "ATM.java" (getters and setters). Note that the user can withdraw at most 5 times per day. 

set and get: what they are and how to use these methods correctly

We will learn this lesson of our online Java course the two methods most commonly used by Java programmers: the getters and setters. 

Self-reference with this and How to invoking Classes and Objects methods

In the last tutorial related to Java Object Orientation, we talked about creating constructors, with or without parameters, in our classes. 

In this small class, we will learn how to reference members of an object through the keyword 'this', which is a tool widely used by programmers in Java methods within classes. 

Default constructor and with parameters: what they are, what they are for and how to use

Have you noticed that in the last tutorial on how to declare and create class and instantiate objects, we did: 
Student student = new Student (); 

You noticed how repeated 'Student' twice? 
Why? It is pointless or a waste of time to repeat it? 

In Java - indeed, in programming - everything has a reason. 

In this article you will learn about the constructors and know the reason for the repetition and how to use the methods constructors.