Escolar Documentos
Profissional Documentos
Cultura Documentos
with Java
Topic
Lecture 1
Fundamentals of Java
Operator overloading √ ×
Template classes √ ×
Global variables √ ×
Header files √ ×
Pointers √ ×
Interface and Package × √
API × √
Programming code
Environment Java
c o m p ile r
programming C + + s o u rc e
code
code C J+ +V oMb j e c t
code
independent in te r p r te r
W IN 3 2
in te r p r te r
S o la r is
in te r p r te r
M a c in t o s h
programming
In te l P e n tiu m S u n S o la r is A p p le M a c in to s h
2. class HelloWorldApp {
3. public static void main ( String args[] ) {
4. System.out.println ("Hello Java !");
5. }
6. }
2. import java.awt.Graphics;
3. import java.applet.Applet;
4. public class HelloWorld extends Applet {
5. public void paint (Graphics g ) {
6. g.drawString("Hello World!" 50, 25);
7. }
8. }
class HelloWorldApp {
public static void main ( String args[ ] ) {
System.out.println ("Hello Java !");
}
}
class
public, static, void, main
String args[ ]
System.out.println
P a c k a g e s ta te m e n t (o p tio n a l)
In te rfa c e s ta te m e n t (o p tio n a l)
M a in c la s s d e fin itio n
{
m a in m e th o d d e fin itio n
}
import java.lang.Math;
class SquareRoot
{
public static void main (String args[ ]) {
double x = 45; // Variable declaration and initialization
double y; // Declaration of another variable
y = Math.sqrt (x);
System.out.println("Square root of "+ x +"=" + y);
}
}
class FirstClass {
int idNo;
iIdNo = 555;
public static void print( ) {
System.out.println ( " First Class citizen" + idNo );
}
}
class SecondClass {
int idNo;
idNo = 111;
public static void print( ) {
System.out.println ( " Second Class citizen " + idNo) ;
}
}
p r in c ip a lA m o u n t
n u m b e rO fY e a rs
r a te O fIn te r e s t
tempString = in.readLine();
numberOfYears = Integer.parseInt(tempString);
Im p o rt S e c tio n P a rt 1
p u b lic c la s s N e w A p p le tN a m e e x te n d s A p p le t { P a rt 2
V a ria b le d e c la ra tio n (s ) P a rt 3
P a rt 4
M e th o d (s ) fo r o b je c t in te ra c tio n d e c la re d a n d d e fin e d h e re
J a v a c o d e to a c c o m p lis h e d a ta s k
import java.awt . *;
import java.applet. * ;
< applet code = " RectangleTest" width = 150 height = 100 >
< param name = xValue value = 20 >
< param name = yValue value = 40 >
<param name = wValue value = 100>
< param name = hValue value = 50 >
< /applet >