Variable declaration

Asked

Viewed 51 times

0

I do not know what is the subject of this part of Java, but I did not understand it:

Carro carro;

I know that when declaring the variable we do:

String carro;

Why is there such a thing Carro? and the guys are int, boolean, string, float, double?

Could someone explain something to me please?

2 answers

2


Car is a class created by (you) programmer, and in the statement there you are instantiating the Car class that should stay Carro carro = new Carro(); String, Boolean, and etc are primary (native) language data types. So to speak when Voce uses: String carro; you are using the string class (Java native language) and assigning the car name, so a string type variable called car. When you create and use the class, it’s like using "String" but you created the class, its methods and etc, and giving the car name.

In this link you can better understand the function and use of classes which is very important: Click Here

  • I created a Car class, and tried instaciala using Car; as you said and it didn’t work.

  • Test test; test = new Test(); got it

-2

Integer Type. • Table with integer primiCiCvos Java Cpos. Type. Size ... float ( 32-bit accuracy) and double (64-bit accuracy). Type ... Type String ( String).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.