Java

From Torben's Wiki

Basics

String str = new String();

int2String

String anzeigewert = Integer(_wert).toString();

Fields / Lists

private int[] _intlist;
_intlist = new boolean[100];
for(int i=0; i < intlist.length(); i++){ 
};

Switch

switch(watt)
  {
  case  25: _watt =  25; break;
  case  40: _watt =  40; break;
  case  60: _watt =  60; break;
  case 100: _watt = 100; break;
  default : _watt =  25;
}

Casting

Iterator it = dingeListe.iterator(); //(vom Typ 'Object')
Ding ding = (Ding) it.next();

Downcasting

if (dingdong instanceof Ding) {...}

Lists (Vektors)

private Vector liste = new Vector()
liste.add(obj);
size = liste.size();	 
Iterator it = liste.iterator();
while(it.hasNext()) {
  String str = (String) it.next();
}

Eclipse, Export using FatJar

Eclipse Export of Projects that use eternal jars: Use FatJar: http://fjep.sourceforge.net/ It adds the Entry "Build Fat-JAR" to the Export-Wizard. In addition to the eclipse standard jar-exporter referenced classes and jars are included to the "Fat-Jar", so the resulting jar contains all needed classes and can be executed directly with "java -jar", no classpath has to be set, no additional jars have to be deployed.