0% found this document useful (0 votes)
4 views1 page

Tips Java

Useful Java Beginner friendly tips

Uploaded by

silviu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Tips Java

Useful Java Beginner friendly tips

Uploaded by

silviu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Tips & Tricks for Java

Sysout – ctrl+space (System.out.println())

System.out.print (ln) or System.out.print(“blablabla \n”)

Scanner
Import java.util.Scanner;

In main : Scanner *(un nume)* = new Scanner(System.in);

String/char *o variabila* = *(un nume)*.nextLine();

Cand e caracter, sir de caractere nextLine();

Cand e numar, numar cu decimale, etc se pune nextInt(); nextDouble() etc

Inainte de fiecare citire se pune scanner.nexLine(), Int(), Doble(), etc

GUI – Dialog Box


Import.javax.swing.JOptionPane;

In main

Daca variabila este de tip string atunci:

String *var* = JOptionPane.showInputDialog(“*mesaj*”);

Daca varibila e de tip int,double, numeric…. Atunci facem conversia:

int *variabila* = Integer.parseInt(JOptionPane.showInputDialog(“*mesaj*”));

double *variabila* = Double.parseDouble(………);

Pentru afisare:

JOptionPane.showMessageDialog(null, mesaj/variabila/expresie matematica/etc);

You might also like