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.

Accessing and modifying variables from Classes and Objects

We already saw what are the objects and class in Java , how to declare, create a class and instantiate an object ,let's see now, in this section, how to put a few variables within our class and learn how to assign values ​​to them, and how to access them. 

This tutorial is the first step to creating attributes (features) in our classes. 

How to create a Class and declare an Objects in Java

Now that you've read the last article about the usefulness of classes and objects in Java , this tutorial will teach you how to create a class in your IDE and how to instantiate objects of that class. 

For this, we use the concept of Object Orientation, creating a class called Student, which we will use in our next article to contain the name and student grades, as well as access the data and populate these objects.

Object-Orientation

Learn here the main principle of Object-oriented programming (OOP).


Object Orientation, Part I: Creating and declaring classes - Constructors

00. Introduction: Classes and Objects, what are they and for what they serve to
01. How to create a Class and declare an Objects in Java
02. Accessing and modifying variables from Classes and Objects
03. Default constructors and with parameters: what they are, what they are for and how to use
      Video lesson: Constructors



Object Orientation, Part II: Setters and Getters - Composition - enum

Introduction: Classes and Objects, what are they and for what they serve



The concept of object orientation is, undoubtedly, the most important in Java programming language.
And that is why we will teach from the beginning, in our Java course.

Being a somewhat abstract concept, it is normal to take a while to understand everything. And to get it right, it will take longer.
However, we teach over several tutorials, divided into various sections, such as important details.

In this part, as we have seen only the basics of Java programming and loops, we only teach how to declare classes, instantiate objects (with and without constructors) and how to use conditional tests within the classes we create.
This will give an idea of ​​what are classes and objects, and it is important you get used to these ideas.

Arrays Class: Learn how to handle (copy, sort, search and manipulate) Arrays


One of the great advantages of programming in Java is that it provides us a tremendous amount of APIs. We mean, Java comes with many classes and methods ready to be used.

In this tutorial in our online and free Java course will learn to use the Arrays class and its main methods, ordering, comparing, look, put elements in arrays / vectors of utilities among other series.

Exercise: Method that receives any number of arguments (...)


Solved and commented Java exercise:
A teacher, very cool, did 3 tests during a semester but will only take into account the two highest grades to average.
Write a Java application that asks the value of 3 notes, show how it would mean to these 3 tests, average with the 2 highest grades, as well as his highest score and your lowest note. These averages must be calculated using the same method, because you're a Java programmer and will not create a lot of methods for nothing.
Create another method that receives all 3 grades and returns the largest. And another that returns the smallest.

Varargs - passing a list of arguments, of any size, to a method


So far, in our Java course, always specify the exact number of arguments that a method must receive.
When we will study Arrays and ArrayLists - soon , we should see that we can pass any number of values ​​to the methods.

But there is another way to do this in Java, using the ellipsis: ...
Using this, we can move one, two, three or any number of arguments to a method that it will know how to handle this data.

Arrays in Methods: pass by value and pass by reference


We saw in our Java course that there is a section just for methods, and we are in another section of the course just to arrays.
There are two important things, and the interaction between them is also important.
However, there are some details that need to be clarified and commented that we'll see in this article.

Java Video Lesson about Arrays and Multidimensional Arrays

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 Arrays and Multidimensional Arrays in Java.

Java Video Lessons - using loop and control statements WHILE, FOR, DO WHILE and SWITCH


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 loops and control statements in Java.

Java Video lesson - How to use the conditional test IF ELSE

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 IF conditional test in Java.
We already explained about how to use IF and ELSE conditionals test.

Java Video lesson: How to use the Scanner Class

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 how to get the user input.
We already explained about how to get user input by Scanner Class