aus Kapitel 1:
-----------------------------------------------------------------------------------------------------------------------
public class Test01 {
 public static void main(String[] args) {
 System.out.println("Erstes Programm");
 }
}

aus Kapitel 2:
-----------------------------------------------------------------------------------------------------------------------
public class Einfuehrung01  {
 public static void main(String[] args) {
 // Datenbeschreibung   = Womit?
 // Methoden       = Was?
 // Steueranweisungen    = In welcher Reihenfolge?
 }
}

public class Einfuehrung02 {
 public static void main (String[] args)  {
  String text;     // Objektreferenz erzeugen
  text = new String("Hallo ");  // Objekt im Speicher anlegen
  text = text.concat("Welt");   // Nachricht senden
  System.out.println(text);   // Nachricht senden
 }
}

public class Laufzeitfehler01 {
  static void main(String[] args)  {
   String name = new String("Merker");       
   System.out.println(name);
 }
}

class Logische01 {
  public static void main(String[] args)  {
  String text;       
  text = new String("Hallo ");
  System.out.println(text);    
  text = text.concat("Welt");   
 }
}

public class Syntax01 {
 public static void main(String args[])  {
   int summe;   
   Summe = 2000;   
   System.out.println(summe);
 }
}

class Syntax02 {
  public static void main(String[] args)  {
  String str = new String("Merker"); // Semikolon und Init.
  System.out.println(str);
 }
}
public class Syntax03  {
 public static void main(String[] args) {
  A a = new A();  // Instanz der Klasse A erzeugen
  System.out.println("Hallo");
 }
}
class A {}

public class Trash01 { public static void main
(String[] args){int
  summe;summe=
  2000;System.out.println(summe);}}



aus Kapitel 3:
-----------------------------------------------------------------------------------------------------------------------
public class Ascii01 {
 public static void main(String args[]) {
  char zeichen = 'A';     
  System.out.println(zeichen);
 }
}

public class Ascii02 {
 public static void main(String args[]) {
  char zeichen = 'A';     
  System.out.println((byte)zeichen);
 }
}

public class Ascii03 {
 public static void main(String args[]) {
  char zeichen = 'A';     
  System.out.println(Integer.toBinaryString(zeichen));
  System.out.println(Integer.toHexString(zeichen));
 }
}

public class Ascii04 {
 public static void main(String args[]) {
  String bits = "1000001";     
  System.out.println((char)Integer.parseInt(bits, 2));
 }
}

public class Ascii05 {
 public static void main(String args[]) {
  String bits = "5A";     
  System.out.println((char)Integer.parseInt(bits, 16));  }
}

public class Ascii06 {
 public static void main(String args[]) {
  char zeichen = '€';    // Euro-Zeichen  
  System.out.println(zeichen);
 }
}

public class Ascii07 {
 public static void main(String args[])  {
  int zahl = 270;         
  System.out.println(Integer.toBinaryString(zahl));
 }
}

import java.net.*;
import java.applet.*;
class Sound01 {
   public static void main(String[] args) throws Exception {
  URL url = new URL("file:///c:/windows/media/chord.wav");  AudioClip clip = Applet.newAudioClip(url);
  clip.play();              
  }
}

public class Unicode01 {
 public static void main(String args[])  {
  char c = '%';     
  System.out.println(c);
 }
}

public class Unicode02 {
 public static void main(String args[])  {
  char c = '€';     
  System.out.println(c);
 }
}

public class Unicode03 {
 public static void main (String args[]) throws Exception {
 
  // ASCII als nach Unicode konvertieren
  byte[] ascii = {'a', 'b', 'c'};
  String str = new String(ascii, "ISO-8859-1");
  System.out.println(str);
 
  // Unicode (UTF-16) nach UTF-8 konvertieren
  byte[] utf8 = str.getBytes("UTF8");
  for (int i=0; i<utf8.length; i++)
    System.out.println((char)utf8[i]);
 }
}


aus Kapitel 4:
-----------------------------------------------------------------------------------------------------------------------
public class Boolean01  {
 public static void main (String args[])  {
  boolean aussage = false;
  System.out.println("Aussage ist: " + aussage);
  System.out.println("d.h. sie ist nicht: " + !aussage);
 }
}

import java.io.*;
import java.util.Scanner;
public class Boolean02  {
 public static void main(String[] args)  {
  Scanner eingabe = new Scanner(System.in);  
  boolean wahr;            
  wahr = eingabe.nextBoolean();         // Eingabe
  System.out.println("Ergebnis ist: " + wahr); // Ausgabe
 }
}

import java.util.Scanner;
public class Byte01 {
 public static void main(String[] args)  {
  Scanner eingabe = new Scanner(System.in);
  byte zahl;          // Deklaration
  zahl = eingabe.nextByte();    // Eingabe
  System.out.println("Eingegeben wurde: " + zahl);
 }
}

public class Character01  {
 public static void main(String[] args) throws Exception  {
  int z;            
  z = System.in.read();   // Liefert den Codepoint
  char c = (char)z;    // Interpretation als (Unicode-)Zeichen
  System.out.println("Ergebnis ist: " + c);
 }
}

public class Deklaration01 {
   public static void main(String[] args) {
     String text;              //Referenzvariable erzeugen
     text = new String("Hallo "); //Objekt erzeugen
     System.out.println(text);    //Objektwert ausgeben
   }
}

public class Deklaration02 {
   public static void main(String[] args) {
     char c  = 'A';
     System.out.println(c);
   }
}

public class Deklaration03  {
 public static void main(String[] args) {
  int zahl1;
  zahl1 = 100;
  System.out.println(zahl1);
 }
}

import java.util.Scanner;
public class Double01 {
 public static void main(String[] args)  {
  Scanner eingabe = new Scanner(System.in);    
  double zahl;              // Deklaration
  zahl = eingabe.nextDouble();      // Einlesen
  System.out.println("Eingegeben wurde: " + zahl);
 }
}

import java.util.Scanner;
public class Integer01 {
 public static void main(String[] args)  {
  Scanner eingabe = new Scanner(System.in);    
  int zahl;           // Deklaration
  zahl = eingabe.nextInt();   // Einlesen
  System.out.println("Eingelesen wurde: " + zahl);
 }
}

import java.util.Scanner;
public class Tauschen01  {
 public static void main(String[] args)  {
  Scanner eingabe = new Scanner(System.in);  
  int z1;
  int z2;            
  System.out.println("Bitte 2 Zahlen eingeben");
  z1 = eingabe.nextInt();
  z2 = eingabe.nextInt();
  System.out.println("Zahl1 = " + z1 + " Zahl2 = " + z2);
  int hilfsvariable = z1;
  z1 = z2;
  z2 = hilfsvariable;
  System.out.println("Zahl1 = " + z1 + " Zahl2 = " + z2);
 }
}

import java.util.Scanner;             
public class Typen01 {                
    public static void main(String[] args) {      
         Scanner eingabe = new Scanner(System.in);    
      int zahl;             
         zahl = eingabe.nextInt();          
         zahl = zahl + 50;           
         System.out.println("Ergebnis ist: " + zahl);
    }                 
}

class Wrapper01 {
 public static void main (String[] args)  {
  Integer zahl = new Integer(25);
  System.out.println(zahl + 3);
 }
}

public class Wrapper02  {
 public static void main(String[] args)   {
  char zeichen1 = 65;
  if (Character.isUpperCase(zeichen1))
    System.out.println("Es ist ein Großbuchstabe");
 }
}

aus Kapitel 5:
-----------------------------------------------------------------------------------------------------------------------
public class Konstanten01 {
  public static void main(String[] args) {
   double geplant = 19.5;    // Variable
   final double MWST = geplant;  // Konstante
   System.out.println(MWST);
 }
}  

class Konstanten02 {
 public static void main(String[] args)  {
  final double PI = 3.14159;
    System.out.println("PI betraegt = " + PI);
 }
}

class Konstanten03 {
 public static void main(String[] args)  {
  // Ganzzahlen
  byte b   = Byte.MAX_VALUE;
  short s  = Short.MAX_VALUE;
  int z    = Integer.MAX_VALUE;
  long l   = Long.MAX_VALUE;
  // Reale Zahlen
  float f  = Float.MAX_VALUE;
  double d = Double.MAX_VALUE;
  System.out.println("b = " + b);
  System.out.println("s = " + s);
  System.out.println("z = " + z);
  System.out.println("l = " + l);
  System.out.println("f = " + f);
  System.out.println("d = " + d);
 }
}

class Literal01 {
 public static void main(String[] args)  {
  int zahl1 = 17;   // Dezimal 17
  int zahl2 = 021;   // Oktal 17
  int zahl3 = 0x0011;  // Hexadezimal 17
  System.out.printf("%d %d %d", zahl1, zahl2, zahl3);
 }
}

class Literal02 {
 public static void main(String[] args)  {
  int zahl1 = 019;  
  System.out.println(zahl1);
 }
}

class Literal03 {
 public static void main(String[] args)  {
  long zahl1 = 12345678901L;  
  System.out.println(zahl1);
 }
}

class Literal04 {
  public static void main(String[] args)  {
  boolean luege = true;
  System.out.println(luege);
 }
}

class Literal05 {
  public static void main(String[] args)  {
  boolean luege = "false";
  System.out.println(false + 3);
 }
}

class Literal06  {
 public static void main(String[] args)  {
  double d1 = 123.45;
  System.out.println(d1);
 }
}

class Literal07 {
 public static void main(String[] args)  {
  double d1 = 12345E-2;
  System.out.println(d1);
 }
}

class Literal08 {
 public static void main(String[] args)  {
  float d1 = 5e-3f;
  System.out.println(d1);
 }
}

class Literal09 {
  public static void main(String[] args)  {
  char zeichen = 'A';
  System.out.println("Das Zeichen ist: " + zeichen);
 }
}

class Literal10 {
  public static void main(String[] args)  {
  char lf = ' ';
  System.out.println("Zeile1" + lf + "Zeile2");
 }
}

public class Literal11 {
 public static void main(String[] args)  {
   String s1 = null;
   System.out.println(s1);
 }  
}

class Literal12 {
  public static void main(String[] args)  {
  String str  = "abc";
  System.out.println("Der String enthaelt: " + str);
 }
}

class Literal13 {
  public static void main(String[] args)  {
  String str  = "Dies ist ein " +
         "langer Text";
  System.out.println(str);
 }
}

import java.awt.*;
class Point01 {
  public static void main(String[] args) {
   Point p;
   p = new Point(5,3);
   System.out.println(p.toString());              
 }
}

import java.awt.*;
class Point02 {
  public static void main(String[] args) {
   Point p1 = new Point(5,3);
   Point p2;
   p2 = p1;     // Wertezuweisung
   System.out.println(p2.toString());              
 }
}

import java.awt.*;
class Point03 {
  public static void main(String[] args) {
   Point p1 = new Point(5,3);
   Point p2;
   p2 = p1;     // Wertezuweisung
   p2.x = 3333;
   p2.y = 4444;
   System.out.println(p1.toString());
   System.out.println(p2.toString());              
 }
}

class String01 {
  public static void main(String[] args) {
   String text;
 }
}

public class String02 {
 public static void main(String[] args)  {
   String str1 = new String("Java");
   String str2 = new String("buch");
   String ergebnis;
   ergebnis = str1.concat(str2);
   System.out.println(ergebnis);
 }
}  

class Variablen01 {
 public static void main(String[] args)  {
  char zeichen;
  double gehalt;
  boolean vorhanden;
 }
}

class Variablen02 {
 public static void main(String[] args)  {
  char zeichen = 'x';
  double gehalt = 2000.00;
  boolean vorhanden= true;
  System.out.println(vorhanden);
 }
}

class Variablen03 {
 public static void main(String[] args)  {
  char zeichen;
  double gehalt;
  boolean vorhanden;
  zeichen = 'x';
  gehalt = 2000;
  vorhanden = true;
  System.out.println(vorhanden);
 }
}

import java.util.Scanner;
public class Tauschen01  {
 public static void main(String[] args)  {
  Scanner eingabe = new Scanner(System.in);  
  int z1;
  int z2;            
  System.out.println("Bitte 2 Zahlen eingeben");
  z1 = eingabe.nextInt();
  z2 = eingabe.nextInt();
  System.out.println("Zahl1 = " + z1 + " Zahl2 = " + z2);
  int hilfsvariable = z1;
  z1 = z2;
  z2 = hilfsvariable;
  System.out.println("Zahl1 = " + z1 + " Zahl2 = " + z2);
 }
}



aus Kapitel 6:
-----------------------------------------------------------------------------------------------------------------------
import java.io.*;
class Console01 {
 public static void main(String[] args) throws Exception {
  int zeichen1 = System.in.read();
  System.out.println(zeichen1);
 }
}

import java.io.*;
class Console02 {
 public static void main(String[] args) throws Exception  {
 int zeichen1 = System.in.read();
 int zeichen2 = System.in.read();
 int zeichen3 = System.in.read();
 System.out.printf("%d %d %d", zeichen1, zeichen2,zeichen3);
 }
}

import java.io.*;
public class Datei01 {
 public static void main(String[] args) throws Exception {
  OutputStream aus = new FileOutputStream("test1.dat");
  DataOutput datenAus = new DataOutputStream(aus);
  datenAus.writeInt(4700);
  datenAus.writeUTF("Merker");
  datenAus.writeUTF("Steinfurt");  
 }
}

import java.io.*;
public class Datei02 {
 public static void main(String[] args) throws Exception {
  InputStream ein = new FileInputStream("test1.dat");
  DataInput datenEin = new DataInputStream(ein);
  int plz = datenEin.readInt();
  String kdname = datenEin.readUTF();
  String ort = datenEin.readUTF();
  System.out.println(plz + " " + kdname + " " + ort);
 }
}

import java.io.*;
class Encode01 {
 public static void main(String[] args) throws Exception {
  Writer writer = new FileWriter("ausgabe.txt");
  writer.write("Java?");
  writer.close();  
 }
}

import java.io.*;
class Encode02 {
 public static void main(String[] args) throws Exception {
  FileOutputStream fos = new FileOutputStream("aus.txt");
  Writer writer = new OutputStreamWriter(fos, "UTF-8");
  writer.write("testing‰");
  writer.close();  
 }
}

class Format01 {
 public static void main(String args[]) {
  float gehalt  = 2000.00f;
  System.out.format("%f ", gehalt);
  System.out.format("%e ", gehalt);
  System.out.format("%g ", gehalt);
 }
}

import java.io.*;
class Format02 {
 public static void main(String args[]) {
  int zahl = 90;
  System.out.format("%1$d / %<o / %<x / %<X ", zahl);
 }
}

import java.io.*;
class Format03  {
 public static void main(String args[]) {
  int monat1 = 5;
  float gehalt1 = 2123.45f;
  String s1 = "Im Monat ";
  String s2 = "haben Sie ";
  String s3 = "%s %02d %s %4.2f verdient ";
  System.out.format(s3, s1, monat1, s2, gehalt1);   
  System.out.format(s3, s1, 11, s2, 983f);
 }
}

import java.io.*;
class Konvert01 {
 public static void main(String[] args) throws Exception {
  OutputStream aus = new FileOutputStream("Stream01.txt");
  DataOutput ausgabe = new DataOutputStream(aus);
  ausgabe.writeInt(174);
 }
}

import java.io.*;
class Konvert02 {
public static void main(String[] args) throws Exception {
 BufferedReader eingabe = new BufferedReader(
 new InputStreamReader(new FileInputStream(
  "Stream01.txt"), "CP1252"));
 BufferedWriter ausgabe = new BufferedWriter(
  new OutputStreamWriter(new FileOutputStream(
   "Stream02.txt"), "UTF-16"));
  int zeichen = eingabe.read();
  ausgabe.write(zeichen);
  zeichen = eingabe.read();
  ausgabe.write(zeichen);
  zeichen = eingabe.read();
  ausgabe.write(zeichen);
  zeichen = eingabe.read();
  System.out.println((char)zeichen);
  ausgabe.close();
 }
}

import java.io.*;
class Konvert03 {
 public static void main(String[] args) throws Exception {
  BufferedReader eingabe = new BufferedReader(
   new InputStreamReader(new FileInputStream(
    "Stream02.txt"), "UTF-16"));
  BufferedWriter ausgabe = new BufferedWriter(
   new OutputStreamWriter(new FileOutputStream(
    "Stream03.txt"), "8859_1"));
  int zeichen = eingabe.read();
  ausgabe.write(zeichen);
  zeichen = eingabe.read();
  ausgabe.write(zeichen);
  zeichen = eingabe.read();
  ausgabe.write(zeichen);
  zeichen = eingabe.read();
  ausgabe.write(zeichen);
  ausgabe.close();
 }
}

import java.io.*;
class Konvert04 {
 public static void main(String[] args) throws Exception {
  InputStream ein = new FileInputStream("Stream03.txt");
  DataInput eingabe = new DataInputStream(ein);
  int zeichen = eingabe.readInt();
  System.out.println(zeichen);
 }
}

class Print01 {
 public static void main(String args[]){
  int monat = 5;
  float gehalt  = 2123.45f;
  String s1 = "Im Monat ";
  String s2 = "haben Sie ";
 
  System.out.print(s1 + monat + " ");
  System.out.print(s2 + gehalt + " ");
  System.out.println("verdient");
 }
}

import java.util.Scanner;
class Scanner01 {
 public static void main(String[] args) {
  Scanner eingabe = new Scanner(System.in);
  String str = eingabe.next();         // Komplettes Wort lesen
  int zahl1  = eingabe.nextInt();      // Ganzzahl lesen
  double zahl2 = eingabe.nextDouble(); // E-Format z.B. 5e3 lesen
  System.out.printf("%s | %d | %f", str, zahl1,zahl2);
 }
}

import java.util.Scanner;
class Scanner03 {
  public static void main(String[] args) throws Exception {
 int zahl;
 Scanner eingabe = new Scanner(System.in);
 String str = eingabe.next();    // Erstes Wort lesen
 zahl = Integer.parseInt(str);   // Konvertieren in Ganzzahl
 System.out.println("Der eingegebene Text ist ok");
   }
}

import java.util.Scanner;
class Scanner04 {
  public static void main(String[] args) {
    Scanner eingabe = new Scanner(System.in);
 eingabe.useDelimiter(",");  // Delimiter aendern
 String str = eingabe.next(); // Komplettes Wort lesen
 int zahl1 = eingabe.nextInt(); // Ganzzahl lesen
 double zahl2 = eingabe.nextDouble(); // E-Format z.B. 5e3 lesen
 System.out.printf("%s | %d | %f", str, zahl1,zahl2);
 }
}

import java.util.Scanner;
class Scanner05 {
 public static void main(String[] args) {
  Scanner eingabe = new Scanner(System.in);
  String zeilenende = System.getProperty("line.separator");
  eingabe.useDelimiter(zeilenende); // Delimiter aendern
  String zeile1 = eingabe.next();  // Komplettes Zeile lesen
  String zeile2 = eingabe.next();  // nächste Zeile lesen
  System.out.printf("%s %s", zeile1, zeile2);
 }
}

import java.io.*;
class Stream01  {
 public static void main(String[] args) throws Exception {
  InputStreamReader eingabe = new InputStreamReader(System.in);
  int zeichen = eingabe.read();
  System.out.println(zeichen);
 }
}

// Kommentarzeile (das erste Zeichen wird gelesen)
import java.io.*;
class Stream02 {
 public static void main(String[] args) throws Exception {
  InputStream eingabe = new FileInputStream("Stream02.java");
  int zeichen = eingabe.read();
  System.out.println(zeichen);
 }
}

import java.io.*;
class Stream03  {
 public static void main(String[] args) throws Exception {
  InputStreamReader eingabe = new InputStreamReader(System.in);
  int zeichen = eingabe.read();
  System.out.println((char)zeichen);
 }
}

import java.net.*;
import java.io.*;
class Stream04 {
 public static void main(String[] args) throws Exception {
  ServerSocket ss = new ServerSocket(1500);
  Socket s = ss.accept();
  DataInputStream ein = new DataInputStream(s.getInputStream());
 
  int zahl = ein.read();
  System.out.println(zahl);
 }
}

import java.io.*;
public class Stream05 {
 public static void main(String[] args) throws Exception  {
  String str = "Dies ist ein Text im Arbeitsspeicher";
  StringReader text = new StringReader(str);
  int c = text.read();
  System.out.print((char)c);
 }
}

import java.util.Scanner;
class TryCatch01 {
 public static void main(String[] args) {
  int zahl;
  Scanner eingabe = new Scanner(System.in);
  String str = eingabe.next();    // Erstes Wort lesen
  try {
    zahl = Integer.parseInt(str); // Konvertieren in Ganzzahl
  }
  catch (NumberFormatException e) {
    System.out.println("Es wurde keine Ganzzahl eingegeben");
    System.exit(8);
  }
  System.out.println("Der eingegebene Text ist ok");
 }
}