


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The first part of java basics tutorial, covering the concept of 'everything is an object' with examples of 'hellodate' and 'exec' classes. It also introduces controlling program flow with operators, if-else, while, do-while, for, and switch statements. Examples are given for vowels and consonants identification.
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Java Basics - Part I
(lectures programs)
Sun OnLine Documentations
Chapter 2: Everything is an Object
First Example: HelloDate
Run as applet
public class HelloDate { public static void main(String[] args) { System.out.println("Hello, it's: "); System.out.println(new Date()); } }
% make OR % javac HelloDate.java
% java HelloDate
% javadoc HelloDate.java
(use netscape to look at the documentation HelloDate.html )
Exec Example: Exec
This excute any program, e.g.:
public class Exec { public static void main(String[] args) { try { String command = args[0];
System.out.println("exec: " + command);
Process p = Runtime.getRuntime().exec(command);
p.waitFor(); } catch (InterruptedException e){} catch (IOException e){} } }
Example: % jave Exec prog Where prog can be:
Note that prog.Who produces no output!
Chapter 3: Controlling Program Flow
Run as applet