140 likes | 287 Views
Programieren in JAVA. Munz – IT/TG - Lörrach. Goals of this “intensive” lecture. To learn: What does it means programming in Java ? What is JAVA good/bad for ? Which programming resources offers JAVA to support “modern” programming ? What is “Object Oriented Programming” ?
E N D
Programieren in JAVA Munz – IT/TG - Lörrach
Goals of this “intensive” lecture • To learn: • What does it means programming in Java ? • What is JAVA good/bad for ? • Which programming resources offers JAVA to support “modern” programming ? • What is “Object Oriented Programming” ? • You should be able to design, write, debug and run Java programs of “certain” complexity • Learning by example
What means “by Example” • A lot of example programs • Little explanation about the details of the syntax • There will be some slides about the Java syntax after we see the examples (shortly) • You will be confronted with the “practical” problems about programming • The reason of many programming “recipes” will became clear as we learn more • Deductive learning/teaching style
Why is JAVA so Popular ? • Multi-platform • Object oriented: the modern programming paradigm • Robust: avoids programming features which can frequently cause errors, permits recovering from errors. • Aware of the Network: easy for developing distributed systems in a TCP/IP network • It is free and has very good documentation
Some historical facts • Java was conceived in 1990 as a microchip programming language for domestic appliances • Java means “coffee” in the USA (programmers drink lot of coffee) • As such it has had not much acceptance (yet) • It was seen that the same characteristics are good for a multi-platform language • The Applets made Java famous
What do I need to develop Java programs • There are many commercial and free developing environments • We will use the most simple and sure, but may be not the most efficient way to develop big applications • We need: • A text editor • The compiler • The JVM The JDK or SDK
How do I write and run a Java Stand-alone Program ? MyProg.class Java VM (java) MyProg.java class { int i,j; public main Java Java compiler (javac) Java source code
How do I write and run a Java-Applet ? MyApplet.class MyApplet.java class { int i,j; public main Java VM (inside the browser) Java source code Java compiler (javac)
What makes Java Multi-platform Java compiler (specific for each platform) javac P1.java Program’s output P1.java P1.class Java interpreter (specific for each platform) also called Java Virtual Machine java P1
How do I get the JDK ?(outside the school) • You can download the JDK from http://java.sun.com/ • There are different versions of JAVA • 1.Java 1.0.x Original version, largely been replaced. • 2.Java 1.1.x Major upgrade from 1.0. (double) Many things in the earlier were deprecated in this version. They still exist and can be used, but there are new (and often better) ways of doing the same things. • 3.Java 1.2.x. Known as Java 2. Doubled the sizeand capabilities of the previous version. This version can be downloaded as an SDK (Software Development Kit). An SDK is the same thing as a JDK, only the name was changed. • 4.Java 1.3.x This version is also known as Java 2, Version 1.3. It is alsoknown as J2SE which stands for Java 2 Standard Edition. • 5.Java 1.4.x This has been released as a beta version
Lecture Content • Einfaches programieren in Java (mit Hilfe der Class Console für I/O) • Variabeln, aritmehmetische Ausdrücke, Datentypen, casts, Bedingungen, Schleifen, Verzweigungen • String-Operationen, Text-orientiertes I/O auf Dateien • Weitere Klassen, package Konzept • Statische Methoden • Class-orientiertes programieren • Klassendefinitionen und Zugriffsrechte • Vererbung, Interfaces und Polymorphie • Graphics und Graphische Schnittstellen
Mein Erstes Programm in Java public classProgramm1{ public static void main(String args[]) { Consolec = new Console(); c.print("Hallo, tipp ein Nummer ein ?"); intdeinnummer = c.readInt(); intmeinnummer = deinnummer+1; c.println(" Mein Nummer lautet " + meinnumer); c.println("Also ich gewinne Diesmal") } } Blau: standart Rot: Datentypen Grün: Variabeln
Mein Zweites Programm public classProgramm2{ public static void main(String args[]) { Consolec = new Console(); c.print("Hallo, wie heist du ?"); Stringname = c.readString(); c.print("Wann bist Du geboren ? (Jahr) "); intjahr = c.readInt(); c.println(name+", also du bist ungefähr "+ (2001-jahr)+" alt "); } } Blau: standart Rot: Datentypen Grün: Variabeln