SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Object Oriented Programming with Java
Topic ,[object Object],[object Object],[object Object],[object Object]
C++ vs. Java ,[object Object],[object Object],[object Object],[object Object],[object Object]
C++ vs. Java ,[object Object],√ × API √ × Interface and Package × √ Pointers × √ Header files × √ Global variables × √ Template classes × √ Operator overloading × √ Multiple Inheritance √ √ Single Inheritance Inheritance √ √ Dynamic √ √ Static Binding √ √ Polymorphism √ √ Data abstraction and encapsulation in Java in C++ Features
C++ vs. Java ,[object Object],[object Object],[object Object]
Fundamentals of Java ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tools Available for Java Programming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tools Available for Java Programming ,[object Object],[object Object],[object Object],[object Object],[object Object]
Tools Available for Java Programming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tools Available for Java Programming ,[object Object],[object Object],[object Object],[object Object],[object Object]
Third Part Tools for Java Programming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Other Third Part Tools  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Programming in Java ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Building a Java Application ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
How to  edit  this program? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
How to  compile  this program? ,[object Object],[object Object],[object Object],[object Object],[object Object]
How to  compile  this program? ,[object Object],[object Object],[object Object]
How to  execute  this program? ,[object Object],[object Object],[object Object],[object Object]
Building a Java Application
Building a Java Application Step 1: Edit and Save
Building a Java Application Step 1: Edit and Save
Building a Java Application Step 1: Edit and Save
Building a Java Application Step 1: Edit and Save
Building a Java Application Step 2: Compile
Building a Java Application Step 2: Compile
Building a Java Application Step 3: Execute
Building a Java Applet ,[object Object]
Building a Java Applet ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Building a Java Applet   Edit  ->  Save  ->  Compile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Building a Java Applet   Execution ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],<applet code = HelloJava.class width = 200 height = 100> </applet>
More on Java Application Structure of a Java Application ,[object Object],[object Object],[object Object],[object Object],[object Object],// Hello Java Application // class  HelloWorldApp {   public static void   main ( String args[ ] )  {   System.out.println  (&quot;Hello  Java !&quot;);    } }
General Structure of an Application
Example: Square Root Calculation /* * One more simple Java Application * * This application computes square root * */ // This is also a comment (one line comment) 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(&quot;Square root of &quot;+ x +&quot;=&quot; + y); } }
Application with Multiple Classes // Application with more than one classes  //  class FirstClass {    intidNo;   iIdNo = 555;   public static void print(  ) {    System.out.println ( &quot; First Class citizen&quot;  + idNo );    } } class SecondClass {    int idNo;   idNo = 111;   public startic void print(  ) {   System.out.println ( &quot; Second Class citizen &quot; + idNo) ;   } }
Application with Multiple Classes (contd..) public class PeopleAppln {   FirstClass female;   SecondClass male;   public static void main( String args[ ] ) {   System.out.print(&quot;People from Java World&quot;);   female.print( );   male.print( );   } }
Application without any Class! // Edit the following program as HelloNoClass.java public static void main (String args[ ] ) {   System.out.println( &quot;Hello Classless Java!]); } Type following two commands to run the Hello.java Application : javac HelloNoClass.java // To compile java  HelloNoClass // To run the program
Communication to Java Application ,[object Object],[object Object],[object Object],[object Object]
Command Line Arguments ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Get Input using  DataInputStream
Get Input using  DataInputStream Calculator Program import java.io.*; class InterestCalculator { public static void main(String args[ ] ) {   Float principalAmount = new Float(0);   Float rateOfInterest = new Float(0);   int numberOfYears = 0;     DataInputStream in = new DataInputStream(System.in);   String tempString;   System.out.print(&quot;Enter Principal Amount: &quot;);   System.out.flush();   tempString = in.readLine();   principalAmount = Float.valueOf(tempString);
Calculator Program (contd..)   System.out.print(&quot;Enter Rate of Interest: &quot;);   System.out.flush();   tempString = in.readLine();   rateOfInterest = Float.valueOf(tempString);   System.out.print(&quot;Enter Number of Years: &quot;);   System.out.flush();     tempString = in.readLine();   numberOfYears = Integer.parseInt(tempString);   // Input is over: calculate the interest   int interestTotal = principalAmount*rateOfInterest*numberOfYears;     System.out.println(&quot;Total Interest = &quot; + interestTotal); } }
Applet Revisited ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Structure of an Applet
Basic Methods in Applet ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Use of init( ) // Use of init( ) method in an applet // import java.awt .Graphics ; import java.applet.Applet; public class HelloWorld extends Applet { public void init( ) {   resize(200,200); } public void paint (Graphics g ) {    g.drawString ( &quot; Hello World !&quot;, 50, 25 ); } }
One More Example: Use of init( ) // Use of  init( ) to pass value through HTML to applet // import java.awt . *; import java.applet. * ; public class RectangleTest extends applet { int x, y, w, h;  public void init (  ) {   x  = Integer.parseInt(get Parameter (&quot; xValue&quot; ));   y  = Integer.parseInt(get Parameter (&quot; yValue&quot; ));   w = Integer.parseInt(get Parameter (&quot; wValue&quot; ));   h  = Integer.parseInt(get Parameter (&quot; hValue&quot; ));  }  public void paint ( Graphics g ) {    g.drawRect (x, y, w, h ); } }
One More Example: Use of init( ) Corresponding HTML document containing this applet and providing  parameter values will be : < applet code = &quot; RectangleTest&quot; 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 >
Application vs. Applet ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Weitere ähnliche Inhalte

Ähnlich wie Javalecture 1

Ähnlich wie Javalecture 1 (20)

Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Introduction to java programming part 1
Introduction to java programming   part 1Introduction to java programming   part 1
Introduction to java programming part 1
 
JAVA introduction and basic understanding.pptx
JAVA  introduction and basic understanding.pptxJAVA  introduction and basic understanding.pptx
JAVA introduction and basic understanding.pptx
 
Java platform
Java platformJava platform
Java platform
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
Curso de Programación Java Básico
Curso de Programación Java BásicoCurso de Programación Java Básico
Curso de Programación Java Básico
 
Introduction
IntroductionIntroduction
Introduction
 
Java introduction
Java introductionJava introduction
Java introduction
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
Java introduction
Java introductionJava introduction
Java introduction
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
INTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATIONINTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATION
 

Kürzlich hochgeladen

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Kürzlich hochgeladen (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

Javalecture 1

  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. Building a Java Application
  • 20. Building a Java Application Step 1: Edit and Save
  • 21. Building a Java Application Step 1: Edit and Save
  • 22. Building a Java Application Step 1: Edit and Save
  • 23. Building a Java Application Step 1: Edit and Save
  • 24. Building a Java Application Step 2: Compile
  • 25. Building a Java Application Step 2: Compile
  • 26. Building a Java Application Step 3: Execute
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. General Structure of an Application
  • 33. Example: Square Root Calculation /* * One more simple Java Application * * This application computes square root * */ // This is also a comment (one line comment) 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(&quot;Square root of &quot;+ x +&quot;=&quot; + y); } }
  • 34. Application with Multiple Classes // Application with more than one classes // class FirstClass { intidNo; iIdNo = 555; public static void print( ) { System.out.println ( &quot; First Class citizen&quot; + idNo ); } } class SecondClass { int idNo; idNo = 111; public startic void print( ) { System.out.println ( &quot; Second Class citizen &quot; + idNo) ; } }
  • 35. Application with Multiple Classes (contd..) public class PeopleAppln { FirstClass female; SecondClass male; public static void main( String args[ ] ) { System.out.print(&quot;People from Java World&quot;); female.print( ); male.print( ); } }
  • 36. Application without any Class! // Edit the following program as HelloNoClass.java public static void main (String args[ ] ) { System.out.println( &quot;Hello Classless Java!]); } Type following two commands to run the Hello.java Application : javac HelloNoClass.java // To compile java HelloNoClass // To run the program
  • 37.
  • 38.
  • 39. Get Input using DataInputStream
  • 40. Get Input using DataInputStream Calculator Program import java.io.*; class InterestCalculator { public static void main(String args[ ] ) { Float principalAmount = new Float(0); Float rateOfInterest = new Float(0); int numberOfYears = 0; DataInputStream in = new DataInputStream(System.in); String tempString; System.out.print(&quot;Enter Principal Amount: &quot;); System.out.flush(); tempString = in.readLine(); principalAmount = Float.valueOf(tempString);
  • 41. Calculator Program (contd..) System.out.print(&quot;Enter Rate of Interest: &quot;); System.out.flush(); tempString = in.readLine(); rateOfInterest = Float.valueOf(tempString); System.out.print(&quot;Enter Number of Years: &quot;); System.out.flush(); tempString = in.readLine(); numberOfYears = Integer.parseInt(tempString); // Input is over: calculate the interest int interestTotal = principalAmount*rateOfInterest*numberOfYears; System.out.println(&quot;Total Interest = &quot; + interestTotal); } }
  • 42.
  • 43. Structure of an Applet
  • 44.
  • 45. Example: Use of init( ) // Use of init( ) method in an applet // import java.awt .Graphics ; import java.applet.Applet; public class HelloWorld extends Applet { public void init( ) { resize(200,200); } public void paint (Graphics g ) { g.drawString ( &quot; Hello World !&quot;, 50, 25 ); } }
  • 46. One More Example: Use of init( ) // Use of init( ) to pass value through HTML to applet // import java.awt . *; import java.applet. * ; public class RectangleTest extends applet { int x, y, w, h; public void init ( ) { x = Integer.parseInt(get Parameter (&quot; xValue&quot; )); y = Integer.parseInt(get Parameter (&quot; yValue&quot; )); w = Integer.parseInt(get Parameter (&quot; wValue&quot; )); h = Integer.parseInt(get Parameter (&quot; hValue&quot; )); } public void paint ( Graphics g ) { g.drawRect (x, y, w, h ); } }
  • 47. One More Example: Use of init( ) Corresponding HTML document containing this applet and providing parameter values will be : < applet code = &quot; RectangleTest&quot; 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 >
  • 48.