Soumettre la recherche
Mettre en ligne
Java Programming Guide Quick Reference
•
3 j'aime
•
859 vues
FrescatiStory
Suivre
Java Programming Guide, Quick Reference
Lire moins
Lire la suite
Technologie
Actualités & Politique
Signaler
Partager
Signaler
Partager
1 sur 11
Télécharger maintenant
Télécharger pour lire hors ligne
Recommandé
Cheat Sheet java
Cheat Sheet java
arkslideshareacc
Gdb cheat sheet
Gdb cheat sheet
Piyush Mittal
Java Cheat Sheet
Java Cheat Sheet
GlowTouch
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Howard Lewis Ship
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
lennartkats
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and Scopes
Eelco Visser
Corejava Online 100
Corejava Online 100
reynolds
Variables: names, bindings, type, scope
Variables: names, bindings, type, scope
suthi
Recommandé
Cheat Sheet java
Cheat Sheet java
arkslideshareacc
Gdb cheat sheet
Gdb cheat sheet
Piyush Mittal
Java Cheat Sheet
Java Cheat Sheet
GlowTouch
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Howard Lewis Ship
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
lennartkats
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and Scopes
Eelco Visser
Corejava Online 100
Corejava Online 100
reynolds
Variables: names, bindings, type, scope
Variables: names, bindings, type, scope
suthi
College Project - Java Disassembler - Description
College Project - Java Disassembler - Description
Ganesh Samarthyam
What's New In Python 2.4
What's New In Python 2.4
Richard Jones
Java session05
Java session05
Niit Care
What's New In Python 2.5
What's New In Python 2.5
Richard Jones
Turmeric SOA Cloud Mashups
Turmeric SOA Cloud Mashups
kingargyle
Java session04
Java session04
Niit Care
Python
Python
Vinayak Hegde
Perl intro
Perl intro
Swapnesh Singh
Project Coin
Project Coin
Balamurugan Soundararajan
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
Coen De Roover
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012
Coen De Roover
Java session08
Java session08
Niit Care
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
Akshay Nagpurkar
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
Sanjeev Tripathi
Java Reference
Java Reference
khoj4u
Understanding the Dalvik bytecode with the Dedexer tool
Understanding the Dalvik bytecode with the Dedexer tool
Gabor Paller
Intro to J Ruby
Intro to J Ruby
Frederic Jean
Java OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
sunny khan
OOP-Chap2.docx
OOP-Chap2.docx
NaorinHalim
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
What is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK Technologies
PSK Technolgies Pvt. Ltd. IT Company Nagpur
Java Basic PART I
Java Basic PART I
Soumen Santra
Contenu connexe
Tendances
College Project - Java Disassembler - Description
College Project - Java Disassembler - Description
Ganesh Samarthyam
What's New In Python 2.4
What's New In Python 2.4
Richard Jones
Java session05
Java session05
Niit Care
What's New In Python 2.5
What's New In Python 2.5
Richard Jones
Turmeric SOA Cloud Mashups
Turmeric SOA Cloud Mashups
kingargyle
Java session04
Java session04
Niit Care
Python
Python
Vinayak Hegde
Perl intro
Perl intro
Swapnesh Singh
Project Coin
Project Coin
Balamurugan Soundararajan
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
Coen De Roover
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012
Coen De Roover
Java session08
Java session08
Niit Care
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
Akshay Nagpurkar
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
Sanjeev Tripathi
Java Reference
Java Reference
khoj4u
Understanding the Dalvik bytecode with the Dedexer tool
Understanding the Dalvik bytecode with the Dedexer tool
Gabor Paller
Tendances
(16)
College Project - Java Disassembler - Description
College Project - Java Disassembler - Description
What's New In Python 2.4
What's New In Python 2.4
Java session05
Java session05
What's New In Python 2.5
What's New In Python 2.5
Turmeric SOA Cloud Mashups
Turmeric SOA Cloud Mashups
Java session04
Java session04
Python
Python
Perl intro
Perl intro
Project Coin
Project Coin
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012
Java session08
Java session08
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
Java Reference
Java Reference
Understanding the Dalvik bytecode with the Dedexer tool
Understanding the Dalvik bytecode with the Dedexer tool
Similaire à Java Programming Guide Quick Reference
Intro to J Ruby
Intro to J Ruby
Frederic Jean
Java OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
sunny khan
OOP-Chap2.docx
OOP-Chap2.docx
NaorinHalim
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
What is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK Technologies
PSK Technolgies Pvt. Ltd. IT Company Nagpur
Java Basic PART I
Java Basic PART I
Soumen Santra
Java programming basics
Java programming basics
Hamid Ghorbani
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
AKR Education
Java introduction
Java introduction
The icfai university jaipur
Quick Intro To JRuby
Quick Intro To JRuby
Frederic Jean
Shiksharth com java_topics
Shiksharth com java_topics
Rajesh Verma
Introduction java programming
Introduction java programming
Nanthini Kempaiyan
Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)
Nuzhat Memon
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
Agora Group
Jvm internals
Jvm internals
Luiz Fernando Teston
Chapter 2 java
Chapter 2 java
Ahmad sohail Kakar
Programming in Java
Programming in Java
Abhilash Nair
Java programing language unit 1 introduction
Java programing language unit 1 introduction
chnrketan
Java basic
Java basic
Arati Gadgil
Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Ajin Abraham
Similaire à Java Programming Guide Quick Reference
(20)
Intro to J Ruby
Intro to J Ruby
Java OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
OOP-Chap2.docx
OOP-Chap2.docx
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
What is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK Technologies
Java Basic PART I
Java Basic PART I
Java programming basics
Java programming basics
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
Java introduction
Java introduction
Quick Intro To JRuby
Quick Intro To JRuby
Shiksharth com java_topics
Shiksharth com java_topics
Introduction java programming
Introduction java programming
Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
Jvm internals
Jvm internals
Chapter 2 java
Chapter 2 java
Programming in Java
Programming in Java
Java programing language unit 1 introduction
Java programing language unit 1 introduction
Java basic
Java basic
Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Plus de FrescatiStory
Șomerul
Șomerul
FrescatiStory
Colina crucilor, Lituania
Colina crucilor, Lituania
FrescatiStory
Palatul lui Gigi Becali
Palatul lui Gigi Becali
FrescatiStory
Le marché aux oignons à Berne, Suisse
Le marché aux oignons à Berne, Suisse
FrescatiStory
Photos inusitées
Photos inusitées
FrescatiStory
Beautiful Greece
Beautiful Greece
FrescatiStory
Crucea Caraiman (Crucea Eroilor Neamului)
Crucea Caraiman (Crucea Eroilor Neamului)
FrescatiStory
A fi părinte în lumea animalelor - Parenting Moments in the Animal World
A fi părinte în lumea animalelor - Parenting Moments in the Animal World
FrescatiStory
România. Lecția de istorie
România. Lecția de istorie
FrescatiStory
Islamism
Islamism
FrescatiStory
Alertă medicală - Un osuț foarte ascuțit
Alertă medicală - Un osuț foarte ascuțit
FrescatiStory
Oameni, destine
Oameni, destine
FrescatiStory
Large Easter eggs around the world
Large Easter eggs around the world
FrescatiStory
Patru secrete ale telefonului tău mobil
Patru secrete ale telefonului tău mobil
FrescatiStory
Populația mahomedană în Europa
Populația mahomedană în Europa
FrescatiStory
Bucovina altui veac
Bucovina altui veac
FrescatiStory
Plus qu’une photo / Mai mult decât o simplă fotografie / More than just a photo
Plus qu’une photo / Mai mult decât o simplă fotografie / More than just a photo
FrescatiStory
Noiembrie frumoasă
Noiembrie frumoasă
FrescatiStory
Niciodata toamna n-a fost mai frumoasa
Niciodata toamna n-a fost mai frumoasa
FrescatiStory
Salina Turda
Salina Turda
FrescatiStory
Plus de FrescatiStory
(20)
Șomerul
Șomerul
Colina crucilor, Lituania
Colina crucilor, Lituania
Palatul lui Gigi Becali
Palatul lui Gigi Becali
Le marché aux oignons à Berne, Suisse
Le marché aux oignons à Berne, Suisse
Photos inusitées
Photos inusitées
Beautiful Greece
Beautiful Greece
Crucea Caraiman (Crucea Eroilor Neamului)
Crucea Caraiman (Crucea Eroilor Neamului)
A fi părinte în lumea animalelor - Parenting Moments in the Animal World
A fi părinte în lumea animalelor - Parenting Moments in the Animal World
România. Lecția de istorie
România. Lecția de istorie
Islamism
Islamism
Alertă medicală - Un osuț foarte ascuțit
Alertă medicală - Un osuț foarte ascuțit
Oameni, destine
Oameni, destine
Large Easter eggs around the world
Large Easter eggs around the world
Patru secrete ale telefonului tău mobil
Patru secrete ale telefonului tău mobil
Populația mahomedană în Europa
Populația mahomedană în Europa
Bucovina altui veac
Bucovina altui veac
Plus qu’une photo / Mai mult decât o simplă fotografie / More than just a photo
Plus qu’une photo / Mai mult decât o simplă fotografie / More than just a photo
Noiembrie frumoasă
Noiembrie frumoasă
Niciodata toamna n-a fost mai frumoasa
Niciodata toamna n-a fost mai frumoasa
Salina Turda
Salina Turda
Dernier
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Safe Software
The transition to renewables in India.pdf
The transition to renewables in India.pdf
Competition Advisory Services (India) LLP
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
HostedbyConfluent
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
Padma Pradeep
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
AndikSusilo4
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
Neo4j
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Alan Dix
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
null - The Open Security Community
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Delhi Call girls
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
ThousandEyes
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
carlostorres15106
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
soniya singh
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
comworks
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
Allon Mureinik
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
Hyundai Motor Group
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
Mark Billinghurst
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
Deakin University
Dernier
(20)
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
The transition to renewables in India.pdf
The transition to renewables in India.pdf
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
Java Programming Guide Quick Reference
1.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference Syntax for a standalone application in Java: Java Comments: class <classname> Delimiters Use { // Used for commenting a single line public static void main(String args[]) { /* ————— */ Used for commenting a block of code statements; ————————; /** —————*/ Used for commenting a block of code. ————————; Used by the Javadoc tool for } generating Java documentation. } Primitive datatypes in Java: Steps to run the above application: 1. Type the program in the DOS editor or notepad. Save the DataType Size Default Min Value file with a .java extension. Max Value 2. The file name should be the same as the class, which has the byte main method. (Signed -128 3. To compile the program, using javac compiler, type the integer) 8 bits 0 +127 following on the command line: Syntax: javac <filename.java> short Example: javac abc.java (Signed -32,768 4. After compilation, run the program using the Java integer) 16 bits 0 +32,767 interpreter. Syntax: java <filaname> (without the .java int extension) (Signed -2,147,483,648 Example: java abc integer) 32 bits 0 +2,147,483,647 5. The program output will be displayed on the command line. long -9, 223, 372,036,854, (Signed 775,808, Integer) +9,223,372,036, 64 bits 0 854, 775, 807 © 1999, Pinnacle Software Solutions Inc. 1 © 1999, Pinnacle Software Solutions Inc. 3 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference Java reserved words: abstract default if package this float 32 bits 0.0 1.4E-45 boolean do implements private throw (IEEE 754 3.4028235E38 Break double import protected throws floating-point) Byte else instanceof public transient case extends int return null double 64 bits 0.0 4.9E-324 try Const for new switch (IEEE 754 1.7976931348623157E308 continue while goto synchronized super floating-point) Catch final interface short void char finally long static volatile class float native char 16 bits u0000 u0000 (Unicode character) uFFFF Java naming conventions: boolean 1 bit false Variable Names: Can start with a letter, ‘$’ (dollar symbol), or ‘_’ (underscore); cannot start with a number; cannot be a reserved word. Variable Declaration: Method Names: Verbs or verb phrases with first letter in <datatype> <variable name> lowercase, and the first letter of subsequent words Example: int num1; capitalized; cannot be reserved words. Example: setColor() Variable Initialization: <datatype> <variable name> = value Class And Interface Names: Descriptive names Example: double num2 = 3.1419; that begin with a capital letter, by convention; cannot be a reserved word. Escape sequences: Literal Represents Constant Names: They are in capitals. n New line Example: Font.BOLD, Font.ITALIC t Horizontal tab b Backspace r Carriage return © 1999, Pinnacle Software Solutions Inc. 2 © 1999, Pinnacle Software Solutions Inc. 4
2.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference 5. Switch statement f Form feed Syntax: Backslash switch(variable) ” Double quote { ddd Octal character case(value1): xdd Hexadecimal character statements; udddd Unicode character break; case(value2): statements; Arrays: An array which can be of any datatype, is created in break; two steps – array declaration and memory allocation. default: statements; Array declaration break; <datatype> [] <arr ```````````ayname>; } Examples int[] myarray1; double[] myarray2; Class Declaration: A class must be declared using the Memory Allocation keyword class followed by the class name. The new keyword allocates memory for an array. Syntax Syntax class <classname> <arrayname> = new <array type> [<number of { elements>]; ———— Body of the class Examples myarray1 = new int[10]; A typical class declaration is as follows: Myarray2 = new double[15]; <modifier> class <classname> extends <superclass name> implements <interface name> Multi-dimensional arrays: { —————Member variable declarations; Syntax: —————Method declarations and definitions <datatype> <arrayname> [] [] = new <datatype> } [number of rows][number of columns]; Example: int mdarray[][] = new int[4][5]; © 1999, Pinnacle Software Solutions Inc. 5 © 1999, Pinnacle Software Solutions Inc. 7 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference Flow Control: Member variable declarations: 1. If……..else statements <access specifier> <static/final/transient/ Syntax: volatile> <datatype> <variable name> if(condition) Example public final int num1; { statements; Method declarations: } else <access specifier> <static/final> <return type> { <method name> <arguments list> statements; { } Method body; } 2. For loop Example public static void main(String args[]) Syntax: { for(initialization; condition; increment) } { statements; Interface declaration: Create an interface. Save the file } with a.java extension, and with the same name as the interface. Interface methods do not have any implementation 3. While loop and are abstract by default. Syntax: while(condition) Syntax { interface <interface name> statements; { } void abc(); void xyz(); 4. Do….While loop } Syntax: do Using an interface: A class implements an interface with the { implements keyword. statements; } while(condition); © 1999, Pinnacle Software Solutions Inc. 6 © 1999, Pinnacle Software Solutions Inc. 8
3.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference Syntax class <classname> extends <superclass name> implements <interface name> final Class Cannot be subclassed. { class body; Method Cannot be overridden. —————————; } Variable Value cannot be changed (Constant) Creating A Package: native Method Implemented in a language 1. Identify the hierarchy in which the .class files have to other than Java like C,C++, be organized. assembly etc. Methods do not 2. Create a directory corresponding to every package, with have bodies. names similar to the packages. 3. Include the package statement as the first statement in static Method Class method. It cannot refer to the program. nonstatic variables and methods 4. Declare the various classes. of the class. Static methods are 5. Save the file with a .java extension. implicitly final and invoked 6. Compile the program which will create a .class file in through the class name. the same directory. 7. Execute the .class file. Variable Class variable. It has only one copy regardless of how many Packages and Access Protection: instances are created. Accessed only through the class name. Accessed Public Protected Package Private From the synchronized Method A class which has a synchronized same class ? Yes Yes Yes Yes method automatically acts as a lock. Only one synchronized From a non method can run for each class. subclass in the same package ? Yes Yes Yes No © 1999, Pinnacle Software Solutions Inc. 9 © 1999, Pinnacle Software Solutions Inc. 11 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference List of exceptions in Java(part of java.lang package): From a non subclass Essential exception classes include - outside the package? Yes No No No Exception Description From a ArithmeticException Caused by exceptional subclass conditions like divide by in the same zero package? Yes Yes Yes No ArrayIndexOfBounds Thrown when an array is From a Exception accessed beyond its bounds subclass outside the ArrayStoreException Thrown when an incompatible package ? Yes Yes No No type is stored in an array ClassCastException Thrown when there is an invalid cast Attribute modifiers in Java: IllegalArgument Thrown when an inappropriate Modifier Acts on Description Exception argument is passed to a method abstract Class Contains abstract methods.Cannot IllegalMonitorState Illegal monitor operations such as be instantiated. Exception waiting on an unlocked thread Interface All interfaces are implicitly IllegalThreadState Thrown when a requested abstract. The modifier is Exception operation is incompatible with optional. the current thread state. Method Method without a body. IndexOutOfBounds Thrown to indicate that an index Signature is followed by a Exception is out of range. semicolon. The class must also be abstract. NegativeArraySize Thrown when an array is created Exception with negative size. © 1999, Pinnacle Software Solutions Inc. 10 © 1999, Pinnacle Software Solutions Inc. 12
4.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference NullPointerException Invalid use of a null reference. setPriority() Changes the priority of the thread NumberFormatException Invalid conversion of a string to a currentThread() Returns a reference to the number. currently executing thread SecurityException Thrown when security is violated. activeCount() Returns the number of active threads in a thread group ClassNotFound Thrown when a class is not found. Exception Exception Handling Syntax: CloneNotSupported Attempt to clone an object that Exception does not implement the Cloneable try interface. { //code to be tried for errors IllegalAccess Thrown when a method does not } Exception have access to a class. catch(ExceptionType1 obj1) { Instantiation Thrown when an attempt is made //Exception handler for ExceptionType1 Exception to instantiate an abstract class or } an interface. catch(ExceptionType2 obj2) { InterruptedException Thrown when a second thread //Exception handler for ExceptionType2 interrupts a waiting, sleeping, or } paused thread. finally{ //code to be executed before try block ends. This executes whether or not an // exception occurs in the try block. } The java.lang.Thread class I/O classes in Java (part of the java.io package): The Thread class creates individual threads. To create a thread I/O class name Description either (i) extend the Thread class or (ii) implement the Runnable interface. In both cases, the run() method defines operations BufferedInputStream Provides the ability to buffer the © 1999, Pinnacle Software Solutions Inc. 13 © 1999, Pinnacle Software Solutions Inc. 15 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference performed by the thread. input. Supports mark() and Methods of the Thread class: reset() methods. BufferedOutputStream Provides the ability to write bytes Methods Description to the underlying output stream without making a call to the run() Must be overridden by underlying system. Runnable object; contains code that the thread should perform BufferedReader Reads text from a character start() Causes the run method to input stream execute and start the thread BufferedWriter Writes text to character output stream sleep() Causes the currently executing DataInputStream Allows an application to read thread to wait for a specified time primitive datatypes from an before allowing other threads to underlying input stream execute DataOutputStream Allows an application to write primitive datatypes to an output interrupt() Interrupts the current thread stream File Represents disk files and Yield() Yields the CPU to other runnable directories threads FileInputStream Reads bytes from a file in a file system getName() Returns the current thread’s name FileOutputStream Writes bytes to a file ObjectInputStream Reads bytes i.e. deserializes getPriority() Returns the thread’s priority as an objects using the integer readObject() method ObjectOutputStream Writes bytes i.e. serializes isAlive() Tests if the thread is alive; returns objects using the a Boolean value writeObject()method PrintStream Provides the ability to print join() Waits for specified number of different data values in an milliseconds for a thread to die efficient manner RandomAccessFile Supports reading and writing to setName() Changes the name of the thread a random access file © 1999, Pinnacle Software Solutions Inc. 14 © 1999, Pinnacle Software Solutions Inc. 16
5.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference StringReader Character stream that reads getName() Returns the name of the file and directory from a string denoted by the path name isDirectory() Tests whether the file represented by the StringWriter Character stream that writes to pathname is a directory a StringBuffer that is later lastModified() Returns the time when the file was last converted to a String modified l length() Returns the length of the file represented by the pathname The java.io.InputStream class: The InputStream class is listFiles() Returns an array of files in the directory at the top of the input stream hierarchy. This is an abstract class represented by the pathname which cannot be instantiated. Hence, subclasses like the setReadOnly() Marks the file or directory so that only DataInputStream class are used for input purposes. read operations can be performed renameTo() Renames the file represented by the Methods of the InputStream class: pathname delete() Deletes the file or directory represented by Method Description the pathname available() Returns the number of bytes that can be canRead() Checks whether the application can read read from the specified file canWrite() Checks whether an application can write to close() Closes the input stream and releases a specified file associated system resources mark() Marks the current position in the input Creating applets: stream mark 1. Write the source code and save it with a .java Supported() Returns true if mark() and reset() methods extension are supported by the input stream 2. Compile the program 3. Create an HTML file and embed the .class file with the read() Abstract method which reads the next byte <applet> tag into it. of data from the input stream 4. To execute the applet, open the HTML file in the browser or use the appletviewer utility, whch is part of the Java read(byte b[]) Reads bytes from the input stream and Development Kit. stores them in the buffer array © 1999, Pinnacle Software Solutions Inc. 17 © 1999, Pinnacle Software Solutions Inc. 19 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference skip() Skips a specified number of bytes from the The <applet> tag: Code, width, and height are input stream mandatory attributes of the <applet> tag. Optional attributes include codebase, alt,name, align, vspace, and hspace. The code attribute takes the name of the class file as The java.io.OutputStream class: The OutputStream class its value. which is at the top of the output stream hierarchy, is also an Syntax: abstract class, which cannot be instantiated. Hence, subclasses <applet code = “abc.class” height=300 like DataOutputStream and PrintStream are used for width=300> output purposes. <param name=parameterName1 value= value1 > <param name=parameterName2 value= value2 > Methods of the OutputStream class: </applet> Method Description Using the Appletviewer: Appletviewer.exe is an application found in the BIN folder as part of the JDK. Once an close() Closes the output stream, and releases HTML file containing the class file is created (eg. abc.html), associated system resources type in the command line: Appletviewer abc.html write(int b) Writes a byte to the output stream java.applet.Applet class: write(byte b[]) Writes bytes from the byte array to the output stream Methods of the java.applet.Applet class: flush() Flushes the ouput stream, and writes Method Description buffered output bytes init() Invoked by the browser or the applet viewer to inform that the java.io.File class: The File class abstracts information applet has been loaded about files and directories. start() Invoked by the browser or the applet viewer to inform that Methods of the File class: applet execution has started stop() Invoked by the browser or the Method Description applet viewer to inform that applet execution has stopped exists() Checks whether a specified file exists © 1999, Pinnacle Software Solutions Inc. 18 © 1999, Pinnacle Software Solutions Inc. 20
6.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference destroy() Invoked by the browser or the setBackground() Sets the background color of the appletviewer to inform that the component applet has been reclaimed by the setForeground() Sets the foreground color of the Garbage Collector component getAppletContext() Determines the applet context or SetSize() Resizes the component the environment in which it runs setLocation() Moves the component to a new getImage() Returns an Image object that can location be drawn on the applet window setBounds() Moves the component to specified location and resizes it to the getDocumentBase() Returns the URL of the HTML page specified size that loads the applet addFocusListener() Registers a FocusListener object to receive focus events getCodeBase() Returns the URL of the applet’s from the component class file addMouseListener() Registers a MouseListener getParameter() Returns the value of a named object to receive mouse events applet parameter as a string from the component showStatus() Displays the argument string on addKeyListener() Registers a KeyListener object the applet’s status to receive key events from the component getGraphics() Returns the graphics context of java.awt.Graphics class: The Graphics class is an this component abstract class that contains all the essential drawing methods update(Graphics g) Updates the component. Calls the like drawLine(), drawOval(), drawRect() and so on. A paint() method to redraw the Graphics reference is passed as an argument to the paint() component. method that belongs to the java.awt.Component class. Methods of the Graphics class: AWT Components: Many AWT classes like Button, Checkbox, Label, TextField etc. are subclasses of the Method Description java.awt.Component class. Containers like Frame and drawLine() Draws a line between (x1,y1) and Panel are also subclasses of components, but can additionally (x2,y2) passed as parameters hold other components. drawRect()/fillRect() Draws a rectangle of specified width and height at a specified © 1999, Pinnacle Software Solutions Inc. 21 © 1999, Pinnacle Software Solutions Inc. 23 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference Label: location Constructors drawOval()/fillOval() Draws a circle or an ellipse that · Label() - Creates an empty label fills within a rectangle of specified · Label(String s) - Creates a label with left coordinates justified text string drawString() Draws the text given as a · Label (String s, int alignment) - Creates specified string a label with the specified text and specified aligment. drawImage() Draws the specified image onto Possible values for alignment could be Label.RIGHT, the screen Label.LEFT, or Label.CENTER drawPolygon() /fillPolygon() Draws a closed polygon defined Methods of the Label class: by arrays of x and y coordinates Method Description setColor() Sets the specified color of the graphics context getAlignment() Returns an integer representing the current alignment of the Label. setFont() Sets the specified font of the 0 for left, 1 for center, and 2 for graphics context right alignment. setAlignment() Sets the alignment of the Label to the specified one java.awt.Component class: The Component class is an getText() Returns the label’s text as a abstract class that is a superclass of all AWT components. A string component has a graphical representation that a user can setText() Sets the label’s text with the interact with. For instance, Button, Checkbox, specified string TextField, and TextArea. Methods of the Component class: Button: Method Description Constructors paint(Graphics g) Paints the component. The Button() - Creates a button without a label Graphics context g is used for Button(String s) - Creates a button with the specified painting. label © 1999, Pinnacle Software Solutions Inc. 22 © 1999, Pinnacle Software Solutions Inc. 24
7.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference Methods of the Button class: Choice() - Creates a new choice menu, and presents a pop- Method Description up menu of choices. addActionListener() Registers an ActionListener object to receive action events Methods of the Choice class: from the button Method Description getActionCommand() Returns the command name of the action event fired by the add() Adds an item to a choice menu button. Returns the button label if the command name is null. addItem() Adds an item to a choice menu GetLabel() Returns the button’s label addItemListener() Registers an ItemListener object to receive item events from the SetLabel() Sets the button’s label to the Choice object specified string getItem() Returns the item at the specified index as a string Checkbox: getItemCount() Returns the number of items in the Constructors choice menu · Checkbox() - Creates a checkbox without any label getSelectedIndex() Returns the index number of the · Checkbox(String s) - Creates a checkbox with a currently selected item specified label · Checkbox(String s, boolean state) - Creates getSelectedItem() Returns the currently selected item a checkbox with a specified label, and sets the specified as a string state · Checkbox(String s, boolean state, insert() Inserts a specified item at a specified CheckboxGroup cbg) - Creates a checkbox with a index position specified label and specified state, belonging to a specified checkbox group remove() Removes an item from the choice menu at the specified index © 1999, Pinnacle Software Solutions Inc. 25 © 1999, Pinnacle Software Solutions Inc. 27 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference Methods of the Checkbox class: TextField: Method Description Constructors addItemListener() Registers an ItemListener · TextField() - Creates a new text field object to receive item events from · TextField(int cols) - Creates a text field with the the checkbox specified number of columns · TextField(String s) – Creates a text field initialized with getCheckboxGroup() Returns the checkbox’s group a specified string · TextField(String s, int cols) - Creates a text field getLabel() Returns the checkbox’s label initialized with a specified string that is wide enough to hold a specified number of columns getState() Determines if the checkbox is checked or unchecked Methods of the TextField class: setLabel() Sets the label of the check box Method Description with the specified string isEditable() Returns a boolean value indicating setState() Sets the specified checkbox state whether or not a text field is editable setEditable() Passing True enables text to be Creating Radio Buttons (Mutually exclusive checkboxes): edited, while False disables editing. The default is True. · First create a CheckboxGroup instance – CheckboxGroup cbg = new CheckboxGroup(); addActionListener() Registers an ActionListener · While creating the checkboxes, pass the checkbox group object to receive action events object as an argument to the constructor - Checkbox from a text field (String s, boolean state, CheckboxGroup cbg) getEchoChar() Returns the character used for echoing Choice: getColumns() Returns the number of columns Constructors in a text field © 1999, Pinnacle Software Solutions Inc. 26 © 1999, Pinnacle Software Solutions Inc. 28
8.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference setEchoChar() Sets the echo character for a text Methods of the List class: field getText() Returns the text contained in the Method Description text field setText() Sets the text for a text field add() Adds an item to the end of the scrolling list TextArea: addItemListener() Registers an ItemListener object to receive Item events from Constructors a scrolling list · TextArea() - Creates a new text area deselect() Deselects the item at the specified · TextArea(int rows, int cols) - Creates a new index position empty text area with specified rows and columns · TextArea(String s) – Creates a new text area with the getItem() Returns the item at the specified specified string index position · TextArea(String s, int rows, int cols) - Creates a new text area with the specified string and specified rows getItemCount() Returns the number of items in the and columns. list · TextArea(String s, int rows, int cols, int scrollbars) - Creates a text area with the specified text, getSelectedIndex() Returns the index position of the and rows, columns, and scrollbar visibility as specified. selected item Methods of the TextArea class: getSelectedItem() Returns the selected item on the scrolling list Method Description isMultipleMode() Determines if the scrolling getText() Returns the text contained in the list allows multiple selection text area as a string remove() Removes a list item from a setText() Sets the specified text in the text specified position area setMultipleMode() Sets a flag to enable or disable getRows() Returns the number of rows in the multiple selection © 1999, Pinnacle Software Solutions Inc. © 1999, Pinnacle Software Solutions Inc. Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference Scrollbar: Constructors text area getColumns() Returns the number of columns in · Scrollbar() - Creates a new vertical scroll bar the text area · Scrollbar(int orientation) - Creates a new scroll bar with a particular orientation, which is specified as selectAll() Selects all the text in the text area Scrollbar.HORIZONTAL or Scrollbar.VERTICAL · Scrollbar(int orientation, int value, setEditable() A True value passed as an int visible, int minimum, int maximum)- Creates argument enables editing of the a new scroll bar with the specified orientation, initial value, text area, while False disables thumb size, minimum and maximum values editing. It is True by default. Methods of the Scrollbar class: List: Method Description Constructors addAdjustmentListener() Registers an adjustmentListener object · List() - Creates a new scrolling list to receive adjustment · List(int rows) - Creates a new scrolling list with a events from a scroll bar specified number of visible lines getBlockIncrement() Returns the block · List(int rows, boolean multiple) - Creates a increment of a scrollbar scrolling list to display a specified number of rows. A True as an integer. value for Multiple allows multiple selection, while a False getMaximum() Returns the maximum value allows only one item to be selected. value of a scrollbar as an integer getMinimum() Returns the minimum value of a scrollbar as an integer getOrientation() Returns the orientation of a scrollbar as an integer getValue() Returns the current value of a scrollbar as an integer © 1999, Pinnacle Software Solutions Inc. © 1999, Pinnacle Software Solutions Inc.
9.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference Interface method Description setOrientation() Sets the orientation of a scrollbar setValue() Sets the current value of a actionPerformed() Invoked whenever an ActionEvent scrollbar object is generated (button is setMinimum() Sets the minimum value of a clicked) scrollbar setMaximum() Sets the maximum value of a scrollbar TextListener interface: Implemented by a class to handle text events. Whenever the text value of a component changes, an interface method called textValueChanged is invoked, Frame: which must be overridden in the implementing class. Constructors Interface method Description · Frame() - Creates a new frame without any title textValueChanged() Invoked whenever a Text · Frame(String s) - Creates a new frame with the Event object is generated (text specified title value changes) Menus: AdjustmentListener interface: Implemented by a class that · Can be added only to a frame handles adjustment events. The method · A MenuBar instance is first created as: adjustmentValueChanged(), overridden by the MenuBar mb = new MenuBar(); implementing class is invoked everytime an AdjustmentEvent · The MenuBar instance is added to a frame using the object occurs (when a scrollbar is adjusted). setMenuBar() method of the Frame class as follows: setMenuBar(mb); Interface method Description · Individual menus are created (instances of the Menu class) adjustmentValueChanged() Invoked whenever an and added to the menu bar with the add() method AdjustmentEvent object is generated (when a scrollbar Dialog: Direct subclass of java.awt.Window, which accepts thumb is adjusted) user input. ItemListener interface: Implemented to handle state change events. The method itemStateChanged()must be overridden by the implementing class. © 1999, Pinnacle Software Solutions Inc. 33 © 1999, Pinnacle Software Solutions Inc. 35 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference Constructors Method Description itemStateChanged() Invoked whenever an ItemEvent · Dialog(Frame parent, boolean modal) – Creates a object is generated (a checkbox is new initially invisible Dialog attached to the frame object checked, an item is selected from a parent. The second argument specifies whether the dialog choice menu, or an item is selected box is Modal or Non-modal. from a list) · Dialog (Frame parent, String s, boolean modal) – Same as the above. The second argument specifies the title FocusListener interface: Implemented to receive of the dialog box. notifications whenever a component gains or loses focus. The two methods to be overridden are focusGained() and FileDialog: Direct subclass of Dialog, which displays a dialog focusLost(). The corresponding adapter class is window for file selection. FocusAdapter. Constructors Method Description · FileDialog(Frame f, String s) - Creates a new focusGained() Invoked whenever a component dialog for loading files(file open dialog) attached to the frame gains keyboard focus with the specified title focusLost() Invoked whenever a component · FileDialog(Frame f, String s, int i) - Creates a loses keyboard focus file dialog box with the specified title. The third argument specifies whether the dialog is for loading a file or saving a file. The value of i can be either FileDialog.LOAD or KeyListener interface: Implemented to handle key events. FileDialog.SAVE Each of the three methods – keyPressed(), keyReleased(), keyTyped() – receives a KeyEvent AWT Event Listener interfaces: For every AWT event class object when a key event is generated. there is a corresponding event-listener interface, which is a part of the java.awt.event package and provides the event- Method Description handling methods. KeyPressed() Invoked whenever a key is ActionListener interface: Implemented by a class that pressed handles an action event. The method actionPerformed() must be overridden by the implementing class. keyReleased() Invoked whenever a key is released © 1999, Pinnacle Software Solutions Inc. © 1999, Pinnacle Software Solutions Inc. 36
10.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference keyTyped() Invoked whenever a key is typed windowDeactivated() Invoked when the window is no longer the active window i.e. the window can no longer receive keyboard events MouseListener interface: Implemented by a class handling mouse events. It comprises of five methods invoked when a windowIconified() Invoked when a normal window is MouseEvent object is generated. Its corresponding adapter minimized class is the MouseAdapter class. windowDeiconified() Invoked when a minimized Method Description window is changed to normal state mouseClicked() Invoked when mouse is clicked on a component java.sql.Driver interface: Implemented by every driver mouseEntered() Invoked when mouse enters a class. component Methods of the Driver interface: mouseExited() Invoked when mouse exits a component Method Description mousePressed() Invoked when mouse button is acceptsURL() Returns a Boolean value indicating pressed on a component whether the driver can open a connection to the specified URL mouseReleased() Invoked when mouse button is released on a component connect() Tries to make a database connection to the specified URL MouseMotionListener interface: Implemented by a class getMajorVersion() Returns the driver’s major version for receiving mouse-motion events. Consists of two methods – number mouseDragged() and mouseMoved(), which is invoked when a MouseEvent object is generated. getMinorVersion() Returns the driver’s minor version MouseMotionAdapter is its corresponding adapter class. number © 1999, Pinnacle Software Solutions Inc. 37 © 1999, Pinnacle Software Solutions Inc. 39 Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference jdbcCompliant() Tests whether the driver is a genuine JDBC compliant driver Method Description java.sql.Connection interface: Represents a session with a mouseDragged() Invoked when the mouse is pressed on specific database. SQL statements are executed within a session a component and dragged and the results are returned. mouseMoved() Invoked when mouse is moved over Methods of the Connection interface: a component Method Description WindowListener interface: Implemented by a class to receive window events. It consists of seven different methods to Close() Immediately releases the database handle the different kinds of window events, which are invoked and JDBC resources when a WindowEvent object is generated. Its corresponding adapter class is the WindowAdapter class. commit() Makes all changes since the last commit/rollback permanent, and Method Description releases the database locks held by the connection windowOpened() Invoked when the window is made visible for the first time createStatement() Creates and returns a Statement object. It is used for sending SQL windowClosing() Invoked when the user attempts statements to be executed on the to close the window from the database Windows system menu getMetaData() Returns a DatabaseMetaData windowClosed() Invoked when the window has object that represents metadata been closed as a result of calling about the database the dispose() method isReadOnly() Checks whether the connection is a windowActivated() Invoked when the window is read-only connection made active i.e. the window can receive keyboard events prepareCall() Creates and returns a Callable Statement object, © 1999, Pinnacle Software Solutions Inc. 39 © 1999, Pinnacle Software Solutions Inc. 4
11.
Java Programming Guide
- Quick Reference Java Programming Guide - Quick Reference prepareCall() Creates and returns a CallableStatement object (used for calling database stored procedures) prepareStatement() Creates and returns a PreparedStatement object (used for sending precompiled SQL statements to the database) rollback() Discards all the changes made since the last commit/rollback and releases database locks held by the connection setAutoCommit() Enables or disables the auto commit feature. It is disabled by default java.sql.DriverManager class: Responsible for managing a set of JDBC drivers. It attempts to locate and load the JDBC driver specified by the getConnection() method. Methods of the DriverManager class: Method Description getConnection() Attempts to establish a database connection with the specified database URL, and returns a Connection object getLoginTimeout() Returns the maximum number of seconds a driver can wait when attempting to connect to the database © 1999, Pinnacle Software Solutions Inc. © 1999, Pinnacle Software Solutions Inc. Java Programming Guide - Quick Reference Java Programming Guide - Quick Reference registerDriver() Registers the specified driver with the DriverManager setLoginTimeout() Sets the maximum number of seconds a driver can wait when attempting to connect to the database getDrivers() Returns an enumeration of all the drivers installed on the system getDriver() Returns a Driver object that supports connection through a specified URL © 1999, Pinnacle Software Solutions Inc. © 1999, Pinnacle Software Solutions Inc.
Télécharger maintenant