Core Jawa 111
Core Jawa 111
JIWAJI UNIVERSITY
GWALIOR , (M.P)
SUBMITTED BY – SHRUTI
NARWARE SUBMITTED TO –
DR . ALPANA
SEMESTER – 5TH SEM SHARMA
ROLL NO – 221124049
INTRODUCTION TO JAVA
CS 331
INTRODUCTION
• Present the syntax of Java
• Introduce the Java API
• Demonstrate how to build
• stand-alone Java programs
• Java applets, which run within browsers e.g. Netscape
• Example programs
WHY JAVA?
switch (n + 1) {
case 0: m = n - 1; break;
case 1: m = n + 1;
case 3: m = m * n; break;
default: m = -n; break;
}
• Java also introduces the try statement, about which more
later
JAVA ISN'T C!
import java.awt.*;
import java.util.*;
public class SomethingOrOther {
// object definitions go here
. . .
}
• A class consists of
• a collection of fields, or variables, very much like the
named fields of a struct
• all the operations (called methods) that can be
performed on those fields
• can be instantiated
class Person {
String name;
int age;
void birthday ( ) {
age++;
System.out.println (name + ' is
now ' + age);
}
}
ANOTHER EXAMPLE OF A
CLASS