Java Crash Course: Variables Explained

Publicado el: 15 julio 2021
en el canal de: FullStackCloudDeveloper
1,246
16

Variables Explained

Follow along with the instructions at: https://fullstackclouddeveloper.com/c...

Java is a strongly typed language and it provides built-in primitive types to use as building blocks to create other types. As an object oriented language an unlimited number of reference types are possible and Java has several useful reference types built-in.

Primitive Types

Primitive types represent the basic building blocks needed to create other classes. The primitive types are listed below and we will experiment with each to describe them.

int
long
double
float
boolean
byte
short
char
int

Reference Types

Strings
Dates
Arrays
Lists
Maps

Exercise 3: Print Variable Values

For this exercise, take our Hello, World! application and,

Primitives

Print out a variable value of each primitive type,
Check the minimum and maximum values of type Long and print them out

Strings

Create a String sentence and assign it to a variable then,
Print out the sentence .length(),
Replace the third word in the sentence with a different word and print out the sentence,
Split the sentence into an array of its words,
Print out the array of words,
Print out the fourth word in the sentence

Dates

Create a new Date and assign it to a variable that represents right now,
Print out the date variable,
Get the month for the date variable

Lists

Create an ArrayList variable of type Integer,
Add 5 numbers to the list in random order,
Use the Collections class to sort the list,
Print out the list to see the new sorted order

Maps

Create a Map with String keys and String values,
Add names as keys and addresses as values to create an address book,
Print out the map to see the address book,
Print out the .size() of the map to see how many addresses are in the book,
Get an address for one of the names in the map,
Print out the address


En esta página del sitio puede ver el video en línea Java Crash Course: Variables Explained de Duración hora minuto segunda en buena calidad , que subió el usuario FullStackCloudDeveloper 15 julio 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 1,246 veces y le gustó 16 a los espectadores. Disfruta viendo!