Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Last active January 13, 2020 04:48
Show Gist options
  • Save uncoded-ro/65d828914f0bc080b94a5c13e4ab5a6d to your computer and use it in GitHub Desktop.
Save uncoded-ro/65d828914f0bc080b94a5c13e4ab5a6d to your computer and use it in GitHub Desktop.
public class Tipuri {
// variabila clasa
static int nrObj = 0;
// variabile instanta
byte nByte;
short nShort;
int nInt;
long nLong;
float nFloat;
double nDouble;
boolean bLogic;
char cChar;
public Tipuri() {
nrObj++;
}
@Override
public String toString() {
// variabila locala
String mesaj;
mesaj = "Tipuri " + nrObj + "\n" + " [nByte=" + nByte + ", nShort=" + nShort + ", nInt=" + nInt + ", nLong="
+ nLong + ", nFloat=" + nFloat + ", nDouble=" + nDouble + ", bLogic=" + bLogic + ", cChar=" + cChar
+ "]";
return mesaj;
}
public static void main(String args[]) {
Tipuri t1 = new Tipuri();
t1.nByte = 127;
t1.nShort = 32;
t1.nInt = 143;
t1.nLong = 143L;
t1.nFloat = 143.24F;
t1.nDouble = 143.24;
t1.bLogic = false;
t1.cChar = 'X';
System.out.println(t1);
Tipuri t2 = new Tipuri();
System.out.println(t2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment