public class ArgumentsAlternative {
public static void main (String [] args) {
// wie bei der Bash
// for s in "${a[@]}"
// do
// ...
// done
for(String s:args){
System.out.println(s);
}
}
}
public class Arguments {
public static void main(String[] args) {
Integer i;
for (i = 0; i < args.length; i++) {
System.out.println (args[i]);
}
}
}
public class ArgumentsNumberd {
public static void main (String [] args) {
Integer i;
Integer j;
for (i = 0; i < args.length; i++) {
j = i+1;
System.out.println (j.toString () + ". " + args [i]);
}
}
}
public class ArgumentsSorted {
public static void main (String [] args) {
String[] a = new String [args.length];
Integer i;
Integer j;
String tmp;
for (i = 0; i < args.length; i++)
a [i] = args [i];
for (i = 0; i < a.length; i++) {
for (j = i+1; j < a.length; j++) {
if (a[i].compareTo(a [j]) > 0) {
tmp = a [i];
a [i] = a [j];
a [j] = tmp;
}
}
}
for (i = 0; i < args.length; i++)
System.out.println (a [i]);
}
}
public class BinTreeProg {
public static void main (String [] args) {
Integer i;
String s = null;
try {
s = args [0];
}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println ("Katastrophe");
exit (1);
}
BinTree t = new BinTree (s);
for (i = 1; i < args.length; i++)
t.insert (args [i]);
t.out ();
}
public static class BinTree {
BinTree l;
BinTree r;
String v;
BinTree (String s) {
this.l = null;
this.r = null;
this.v = s;
}
public void insert (String s) {
if (this.v.compareTo (s) < 0) {
if (this.l == null)
this.l = new BinTree (s);
else
this.l.insert (s);
}
else {
if (this.r == null)
this.r = new BinTree (s);
else
this.r.insert (s);
}
}
public void out () {
if (this.l != null)
this.l.out ();
System.out.println (this.v);
if (this.r != null)
this.r.out ();
}
}
}
public class Gauss {
public static void main (String [] args) {
System.out.println (GaussTeacher.gaussteacher (6));
}
}
public class GaussTeacher {
public int gaussteacher (int n) {
if (n > 0) {
return n+gaussteacher (n-1);
}
else
return 0;
}
}
public class Hello {
public static void main(String[] args) {
System.out.println ("Hallo Welt");
}
}
public class RecursiveMethode {
public static void main (String [] args) {
Integer i = gauss (6);
System.out.println ("Ergebnis: " + i.toString ());
}
public static int gauss (int n){
if (n > 0) {
System.out.println (n);
return n + gauss (n-1);
}
else
return 0;
}
}