CodeGym/Java Course/Sintassi Java/Diversi modi per creare variabili

Diversi modi per creare variabili

Disponibile

"Ciao, amico. Ho fatto una copia del tuo contratto per te, per ogni evenienza. Rishi, quel tirchio, è beatamente ignorante. Dovresti vedere le cifre nel mio contratto. Ah!"

"Bel lavoro, Diego. Penso che imparerò molto da te."

"Certo, Amigo. Ci sono troppi stupidi al mondo che vogliono arricchirsi senza fare davvero qualcosa. Ma ci sono ancora più idioti che sono pronti a lavorare gratis. "

"OK, torniamo alla nostra lezione. Ora ti insegnerò diversi modi per creare variabili:"

Esempio Spiegazione
String s1 = new String();
String s2 = "";
Crea due stringhe vuote identiche.
int a;
Crea una intvariabile;
int a = 5;
Crea una intvariabile , denominata a e impostane il valore uguale a5
int a = 5, b = 6;
Crea una intvariabile , denominata ae imposta il suo valore uguale a 5Crea una intvariabile , denominata be imposta il suo valore uguale a6
int a = 5, b = a + 1;
Crea una intvariabile denominata ae imposta il suo valore uguale a 5Crea una intvariabile denominata be imposta il suo valore uguale a6
Date date = new Date();
Crea un oggetto Data. Viene inizializzato alla data e all'ora correnti.
boolean isTrue = true;
Inizializza una booleanvariabile atrue
boolean isLess = (5 > 6);
Assegna falsealla isLessvariabile. Booleanle variabili accettano solo i valori true e false.

"Fantastico, Diego! Metti sempre tutto così chiaro."

"LOL! Grazie, Amigo."

"A proposito, ho ancora un paio di esercizi per te. Come stanno andando finora?"

"Non erano troppo difficili e alcuni erano piuttosto divertenti."

3
Compito
Java Syntax,  livello 2lezione 5
Bloccato
The required number
Imagine that for some reason you need a specific number, and until you get it, nothing good will happen (or something bad will happen). Have you got a picture of that in your mind? Do you have a feel for your role? Good, now let's complete an interesting task. We have some code. You need to comment out as many lines as possible to make the program display the number 19.
1
Compito
Java Syntax,  livello 2lezione 5
Bloccato
Crazy eights
The fact that cats were able to take over the Internet with ease shows that we are far from knowing everything about these cute balls of furs. The only obvious thing is that people without them are worse off than people with them. Let's make the world a better place: create 10 Cat variables and 8 more Cat objects. By the way, does anyone need a kitten?
3
Compito
Java Syntax,  livello 2lezione 5
Bloccato
Pets need people
"You become responsible forever for what you've tamed," said Antoine de Saint-Exupery through the mouth of the Little Prince's fox friend. Let's clean up our program and not leave any animal without a caregiver. We'll create a cat, a dog, and a fish. And a woman. And then we'll assign her as the owner of the fish, dog, and cat. We think she'll like this!
Commenti
  • Popolari
  • Nuovi
  • Vecchi
Devi avere effettuato l'accesso per lasciare un commento
Questa pagina non ha ancora commenti