Skip to content

Instantly share code, notes, and snippets.

@nherbaut
Created September 12, 2023 12:13
Show Gist options
  • Select an option

  • Save nherbaut/4473c2d4e06dd1569c16785f413d0fb6 to your computer and use it in GitHub Desktop.

Select an option

Save nherbaut/4473c2d4e06dd1569c16785f413d0fb6 to your computer and use it in GitHub Desktop.
L2.1.3 Les types de variables

Déclarez de nouvelles variables et intialisez-les.

Questions

  • pouvez-vous réutiliser un nom d'une variable déjà utilisée?
  • pouvez-vous intialiser une variable avec une valeur ne correspondant pas à son type?
    • essayez d'initialiser un int ou un long avec un nombre à virgule. Que se passe-t-il ?
    • essayez d'intiialiser un float ou un long avec un nombre entier. Que se passe-t-il?
    • essayer d'intialiser un char avec un (petit) nombre entier. Que se passe-t-il ?

Utilisez la méthode System.out.println(.); pour afficher vos variables (remplacez le . par un nom de variable

public class TypesL2{
public static void main(String ...args){
int i=1;
float f=123.142f;
double d=1234123412341234.12341234;
long l=12341234121L;
boolean b=true;
char c='c';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment