Java Programming Guide - Quick Reference. Java Programming Guide - Quick Reference. Java Comments: Syntax for a standalone application in Java:
|
|
|
- Brice Gray
- 9 years ago
- Views:
Transcription
1 Syntax for a standalone application in Java: class <classname> public static void main(string args[]) ; ; Steps to run the above application: 1. Type the program in the DOS editor or notepad. Save the file with a.java extension. 2. The file name should be the same as the class, which has the main method. 3. To compile the program, using javac compiler, type the following on the command line: javac <filename.java> Example: javac abc.java 4. After compilation, run the program using the Java interpreter. java <filaname> (without the.java extension) Example: java abc 5. The program output will be displayed on the command line. Java Comments: Delimiters Use // Used for commenting a single line /* */ Used for commenting a block of code /** */ Used for commenting a block of code. Used by the Javadoc tool for generating Java documentation. Primitive datatypes in Java: DataType Size Default Min Value Max Value byte (Signed -128 integer) 8 bits short (Signed -32,768 integer) 16 bits 0 +32,767 int (Signed -2,147,483,648 integer) 32 bits 0 +2,147,483,647 long -9, 223, 372,036,854, (Signed 775,808, Integer) +9,223,372,036, 64 bits 0 854, 775, Java reserved words: abstract default if package this boolean do implements private throw Break double import protected throws Byte else instanceof public transient case extends int return null try Const for new switch continue while goto synchronized super Catch final interface short void char finally long static volatile class float native Java naming conventions: Variable Names: Can start with a letter, $ (dollar symbol), or _ (underscore); cannot start with a number; cannot be a reserved word. Names: Verbs or verb phrases with first letter in lowercase, and the first letter of subsequent words capitalized; cannot be reserved words. Example: setcolor() Class And Interface Names: Descriptive names that begin with a capital letter, by convention; cannot be a reserved word. Constant Names: They are in capitals. Example: Font.BOLD, Font.ITALIC float 32 bits E-45 (IEEE E38 floating-point) double 64 bits E-324 (IEEE E308 floating-point) char 16 bits \u0000 \u0000 (Unicode character) \uffff boolean 1 bit false Variable Declaration: <datatype> <variable name> Example: int num1; Variable Initialization: <datatype> <variable name> = value Example: double num2 = ; Escape sequences: Literal Represents \n New line \t Horizontal tab \b Backspace \r Carriage return 2 4
2 \f Form feed \\ Backslash \ Double quote \ddd Octal character \xdd Hexadecimal character \udddd Unicode character Arrays: An array which can be of any datatype, is created in two steps array declaration and memory allocation. Array declaration <datatype> [] <arr ```````````ayname>; Examples int[] myarray1; double[] myarray2; Memory Allocation The new keyword allocates memory for an array. Syntax <arrayname> = new <array type> [<number of elements>]; Examples myarray1 = new int[10]; Myarray2 = new double[15]; Multi-dimensional arrays: <datatype> <arrayname> [] [] = new <datatype> [number of rows][number of columns]; Example: int mdarray[][] = new int[4][5]; 5. Switch statement switch(variable) case(value1): break; case(value2): break; default: break; Class Declaration: A class must be declared using the keyword class followed by the class name. Syntax class <classname> Body of the class A typical class declaration is as follows: <modifier> class <classname> extends <superclass name> implements <interface name> Member variable declarations; declarations and definitions 5 7 Flow Control: Member variable declarations: 1. If..else statements if(condition) else 2. For loop for(initialization; condition; increment) 3. While loop while(condition) 4. Do.While loop do while(condition); <access specifier> <static/final/transient/ volatile> <datatype> <variable name> Example public final int num1; declarations: <access specifier> <static/final> <return type> <method name> <arguments list> body; Example public static void main(string args[]) 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 and are abstract by default. Syntax interface <interface name> void abc(); void xyz(); Using an interface: A class implements an interface with the implements keyword. 6 8
3 Syntax class <classname> extends <superclass name> implements <interface name> class body; ; Creating A Package: 1. Identify the hierarchy in which the.class files have to be organized. 2. Create a directory corresponding to every package, with names similar to the packages. 3. Include the package statement as the first statement in the program. 4. Declare the various classes. 5. Save the file with a.java extension. 6. Compile the program which will create a.class file in the same directory. 7. Execute the.class file. Packages and Access Protection: Accessed Public Protected Package Private From the same class? Yes Yes Yes Yes From a non subclass in the same package? Yes Yes Yes No final Class Cannot be subclassed. Variable Cannot be overridden. Value cannot be changed (Constant) native Implemented in a language other than Java like C,C++, assembly etc. s do not have bodies. static Class method. It cannot refer to nonstatic variables and methods of the class. Static methods are implicitly final and invoked through the class name. Variable Class variable. It has only one copy regardless of how many instances are created. Accessed only through the class name. synchronized A class which has a synchronized method automatically acts as a lock. Only one synchronized method can run for each class From a non subclass outside the package? Yes No No No From a subclass in the same package? Yes Yes Yes No From a subclass outside the package? Yes Yes No No List of exceptions in Java(part of java.lang package): Essential exception classes include - Arithmetic Caused by exceptional conditions like divide by zero ArrayIndexOfBounds Thrown when an array is accessed beyond its bounds ArrayStore Thrown when an incompatible type is stored in an array Attribute modifiers in Java: Modifier Acts on abstract Class Contains abstract methods.cannot be instantiated. ClassCast IllegalArgument IllegalMonitorState Thrown when there is an invalid cast Thrown when an inappropriate argument is passed to a method Illegal monitor operations such as waiting on an unlocked thread Interface All interfaces are implicitly abstract. The modifier is optional. IllegalThreadState Thrown when a requested operation is incompatible with the current thread state. without a body. Signature is followed by a semicolon. The class must also be abstract. IndexOutOfBounds NegativeArraySize Thrown to indicate that an index is out of range. Thrown when an array is created with negative size
4 NullPointer Invalid use of a null reference. setpriority() Changes the priority of the thread NumberFormat Invalid conversion of a string to a number. currentthread() Returns a reference to the currently executing thread Security ClassNotFound CloneNotSupported IllegalAccess Instantiation Thrown when security is violated. Thrown when a class is not found. Attempt to clone an object that does not implement the Cloneable interface. Thrown when a method does not have access to a class. Thrown when an attempt is made to instantiate an abstract class or an interface. Interrupted Thrown when a second thread interrupts a waiting, sleeping, or paused thread. The java.lang.thread class The Thread class creates individual threads. To create a thread either (i) extend the Thread class or (ii) implement the Runnable interface. In both cases, the run() method defines operations activecount() Returns the number of active threads in a thread group Handling try //code to be tried for errors catch(type1 obj1) // handler for Type1 catch(type2 obj2) // handler for Type2 finally //code to be executed before try block ends. This executes whether or not an // exception occurs in the try block. I/O classes in Java (part of the java.io package): I/O class name BufferedInputStream Provides the ability to buffer the performed by the thread. s of the Thread class: s run() start() sleep() interrupt() Yield() getname() getpriority() isalive() join() setname() Must be overridden by Runnable object; contains code that the thread should perform Causes the run method to execute and start the thread Causes the currently executing thread to wait for a specified time before allowing other threads to execute Interrupts the current thread Yields the CPU to other runnable threads Returns the current thread s name Returns the thread s priority as an integer Tests if the thread is alive; returns a Boolean value Waits for specified number of milliseconds for a thread to die Changes the name of the thread BufferedOutputStream BufferedReader BufferedWriter DataInputStream DataOutputStream File FileInputStream FileOutputStream ObjectInputStream ObjectOutputStream PrintStream RandomAccessFile input. Supports mark() and reset() methods. Provides the ability to write bytes to the underlying output stream without making a call to the underlying system. Reads text from a character input stream Writes text to character output stream Allows an application to read primitive datatypes from an underlying input stream Allows an application to write primitive datatypes to an output stream Represents disk files and directories Reads bytes from a file in a file system Writes bytes to a file Reads bytes i.e. deserializes objects using the readobject() method Writes bytes i.e. serializes objects using the writeobject()method Provides the ability to print different data values in an efficient manner Supports reading and writing to a random access file 14 16
5 StringReader StringWriter Character stream that reads from a string Character stream that writes to a StringBuffer that is later converted to a String The java.io.inputstream class: The InputStream class is at the top of the input stream hierarchy. This is an abstract class which cannot be instantiated. Hence, subclasses like the DataInputStream class are used for input purposes. s of the InputStream class: available() close() mark() mark Supported() read() Returns the number of bytes that can be read Closes the input stream and releases associated system resources Marks the current position in the input stream Returns true if mark() and reset() methods are supported by the input stream Abstract method which reads the next byte ofdata from the input stream read(byte b[]) Reads bytes from the input stream and stores them in the buffer array getname() Returns the name of the file and directory denoted by the path name isdirectory() Tests whether the file represented by the pathname is a directory lastmodified() Returns the time when the file was last modified l length() Returns the length of the file represented by the pathname listfiles() Returns an array of files in the directory represented by the pathname setreadonly() Marks the file or directory so that only read operations can be performed renameto() Renames the file represented by the pathname delete() Deletes the file or directory represented by the pathname canread() Checks whether the application can read from the specified file canwrite() Checks whether an application can write to a specified file Creating applets: 1. Write the source code and save it with a.java extension 2. Compile the program 3. Create an HTML file and embed the.class file with the <applet> tag into it. 4. To execute the applet, open the HTML file in the browser or use the appletviewer utility, whch is part of the Java Development Kit skip() Skips a specified number of bytes from the input stream The java.io.outputstream class: The OutputStream class which is at the top of the output stream hierarchy, is also an abstract class, which cannot be instantiated. Hence, subclasses like DataOutputStream and PrintStream are used for output purposes. s of the OutputStream class: The <applet> tag: Code, width, and height are 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 its value. <applet code = abc.class height=300 width=300> <param name=parametername1 value= value1 > <param name=parametername2 value= value2 > </applet> close() write(int b) write(byte b[]) Closes the output stream, and releases associated system resources Writes a byte to the output stream Writes bytes from the byte array to the output stream Using the Appletviewer: Appletviewer.exe is an application found in the BIN folder as part of the JDK. Once an HTML file containing the class file is created (eg. abc.html), type in the command line: Appletviewer abc.html java.applet.applet class: s of the java.applet.applet class: flush() Flushes the ouput stream, and writes buffered output bytes java.io.file class: The File class abstracts information about files and directories. s of the File class: exists() Checks whether a specified file exists init() start() stop() Invoked by the browser or the applet viewer to inform that the applet has been loaded Invoked by the browser or the applet viewer to inform that applet execution has started Invoked by the browser or the applet viewer to inform that applet execution has stopped 18 20
6 destroy() getappletcontext() getimage() getdocumentbase() getcodebase() getparameter() showstatus() Invoked by the browser or the appletviewer to inform that the applet has been reclaimed by the Garbage Collector Determines the applet context or the environment in which it runs Returns an Image object that can be drawn on the applet window Returns the URL of the HTML page that loads the applet Returns the URL of the applet s class file Returns the value of a named applet parameter as a string Displays the argument string on the applet s status java.awt.graphics class: The Graphics class is an abstract class that contains all the essential drawing methods like drawline(), drawoval(), drawrect() and so on. A Graphics reference is passed as an argument to the paint() method that belongs to the java.awt.component class. setbackground() setforeground() SetSize() setlocation() setbounds() addfocuslistener() addmouselistener() addkeylistener() getgraphics() update(graphics g) Sets the background color of the component Sets the foreground color of the component Resizes the component Moves the component to a new location Moves the component to specified location and resizes it to the specified size Registers a FocusListener object to receive focus events from the component Registers a MouseListener object to receive mouse events from the component Registers a KeyListener object to receive key events from the component Returns the graphics context of this component Updates the component. Calls the paint() method to redraw the component. s of the Graphics class: drawline() Draws a line between (x1,y1) and (x2,y2) passed as parameters drawrect()/fillrect() Draws a rectangle of specified width and height at a specified AWT Components: Many AWT classes like Button, Checkbox, Label, TextField etc. are subclasses of the java.awt.component class. Containers like Frame and Panel are also subclasses of components, but can additionally hold other components location drawoval()/filloval() Draws a circle or an ellipse that fills within a rectangle of specified coordinates drawstring() Draws the text given as a drawimage() drawpolygon() /fillpolygon() setcolor() setfont() specified string Draws the specified image onto the screen Draws a closed polygon defined by arrays of x and y coordinates Sets the specified color of the graphics context Sets the specified font of the graphics context java.awt.component class: The Component class is an abstract class that is a superclass of all AWT components. A component has a graphical representation that a user can interact with. For instance, Button, Checkbox, TextField, and TextArea. s of the Component class: Label: Label() - Creates an empty label Label(String s) - Creates a label with left justified text string Label (String s, int alignment) - Creates a label with the specified text and specified aligment. Possible values for alignment could be Label.RIGHT, Label.LEFT, or Label.CENTER s of the Label class: getalignment() setalignment() gettext() settext() Button: Returns an integer representing the current alignment of the Label. 0 for left, 1 for center, and 2 for right alignment. Sets the alignment of the Label to the specified one Returns the label s text as a string Sets the label s text with the specified string paint(graphics g) Paints the component. The Graphics context g is used for painting. Button() - Creates a button without a label Button(String s) - Creates a button with the specified label 22 24
7 s of the Button class: addactionlistener() getactioncommand() Registers an ActionListener object to receive action events from the button Returns the command name of the action event fired by the button. Returns the button label if the command name is null. Choice() - Creates a new choice menu, and presents a popup menu of choices. s of the Choice class: add() additem() Adds an item to a choice menu Adds an item to a choice menu GetLabel() SetLabel() Checkbox: Returns the button s label Sets the button s label to the specified string additemlistener() getitem() getitemcount() Registers an ItemListener object to receive item events from the Choice object Returns the item at the specified index as a string Returns the number of items in the choice menu Checkbox() - Creates a checkbox without any label Checkbox(String s) - Creates a checkbox with a specified label Checkbox(String s, boolean state) - Creates a checkbox with a specified label, and sets the specified state Checkbox(String s, boolean state, CheckboxGroup cbg) - Creates a checkbox with a specified label and specified state, belonging to a specified checkbox group getselectedindex() getselecteditem() insert() remove() Returns the index number of the currently selected item Returns the currently selected item as a string Inserts a specified item at a specified index position Removes an item from the choice menu at the specified index s of the Checkbox class: TextField: additemlistener() getcheckboxgroup() getlabel() getstate() Registers an ItemListener object to receive item events from the checkbox Returns the checkbox s group Returns the checkbox s label Determines if the checkbox is checked or unchecked TextField() - Creates a new text field TextField(int cols) - Creates a text field with the specified number of columns TextField(String s) Creates a text field initialized with a specified string TextField(String s, int cols) - Creates a text field initialized with a specified string that is wide enough to hold a specified number of columns s of the TextField class: setlabel() Sets the label of the check box with the specified string setstate() Sets the specified checkbox state iseditable() Returns a boolean value indicating whether or not a text field is editable Creating Radio Buttons (Mutually exclusive checkboxes): First create a CheckboxGroup instance CheckboxGroup cbg = new CheckboxGroup(); While creating the checkboxes, pass the checkbox group object as an argument to the constructor - Checkbox (String s, boolean state, CheckboxGroup cbg) Choice: seteditable() addactionlistener() getechochar() getcolumns() Passing True enables text to be edited, while False disables editing. The default is True. Registers an ActionListener object to receive action events from a text field Returns the character used for echoing Returns the number of columns in a text field 26 28
8 setechochar() gettext() settext() Sets the echo character for a text field Returns the text contained in the text field Sets the text for a text field s of the List class: add() Adds an item to the end of the scrolling list TextArea: TextArea() - Creates a new text area TextArea(int rows, int cols) - Creates a new empty text area with specified rows and columns TextArea(String s) Creates a new text area with the specified string TextArea(String s, int rows, int cols) - Creates a new text area with the specified string and specified rows and columns. TextArea(String s, int rows, int cols, int scrollbars) - Creates a text area with the specified text, and rows, columns, and scrollbar visibility as specified. s of the TextArea class: gettext() settext() getrows() Returns the text contained in the text area as a string Sets the specified text in the text area Returns the number of rows in the additemlistener() deselect() getitem() getitemcount() getselectedindex() getselecteditem() ismultiplemode() remove() setmultiplemode() Registers an ItemListener object to receive Item events from a scrolling list Deselects the item at the specified index position Returns the item at the specified index position Returns the number of items in the list Returns the index position of the selected item Returns the selected item on the scrolling list Determines if the scrolling list allows multiple selection Removes a list item from a specified position Sets a flag to enable or disable multiple selection text area getcolumns() Returns the number of columns in the text area selectall() Selects all the text in the text area seteditable() A True value passed as an argument enables editing of the text area, while False disables editing. It is True by default. Scrollbar: Scrollbar() - Creates a new vertical scroll bar Scrollbar(int orientation) - Creates a new scroll bar with a particular orientation, which is specified as Scrollbar.HORIZONTAL or Scrollbar.VERTICAL Scrollbar(int orientation, int value, int visible, int minimum, int maximum)- Creates a new scroll bar with the specified orientation, initial value, thumb size, minimum and maximum values s of the Scrollbar class: List: List() - Creates a new scrolling list List(int rows) - Creates a new scrolling list with a specified number of visible lines List(int rows, boolean multiple) - Creates a scrolling list to display a specified number of rows. A True value for Multiple allows multiple selection, while a False value allows only one item to be selected. addadjustmentlistener() getblockincrement() getmaximum() getminimum() getorientation() getvalue() Registers an adjustmentlistener object to receive adjustment events from a scroll bar Returns the block increment of a scrollbar as an integer. Returns the maximum value of a scrollbar as an integer Returns the minimum value of a scrollbar as an integer Returns the orientation of a scrollbar as an integer Returns the current value of a scrollbar as an integer
9 setorientation() setvalue() setminimum() setmaximum() Frame: Sets the orientation of a scrollbar Sets the current value of a scrollbar Sets the minimum value of a scrollbar Sets the maximum value of a scrollbar Interface method actionperformed() Invoked whenever an ActionEvent object is generated (button is clicked) 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, which must be overridden in the implementing class. Frame() - Creates a new frame without any title Frame(String s) - Creates a new frame with the specified title Interface method textvaluechanged() Invoked whenever a Text Event object is generated (text value changes) Menus: Can be added only to a frame A MenuBar instance is first created as: MenuBar mb = new MenuBar(); The MenuBar instance is added to a frame using the setmenubar() method of the Frame class as follows: setmenubar(mb); Individual menus are created (instances of the Menu class) and added to the menu bar with the add() method Dialog: Direct subclass of java.awt.window, which accepts user input. AdjustmentListener interface: Implemented by a class that handles adjustment events. The method adjustmentvaluechanged(), overridden by the implementing class is invoked everytime an AdjustmentEvent object occurs (when a scrollbar is adjusted). Interface method adjustmentvaluechanged() Invoked whenever an AdjustmentEvent object is generated (when a scrollbar thumb is adjusted) ItemListener interface: Implemented to handle state change events. The method itemstatechanged()must be overridden by the implementing class Dialog(Frame parent, boolean modal) Creates a new initially invisible Dialog attached to the frame object parent. The second argument specifies whether the dialog box is Modal or Non-modal. Dialog (Frame parent, String s, boolean modal) Same as the above. The second argument specifies the title of the dialog box. FileDialog: Direct subclass of Dialog, which displays a dialog window for file selection. itemstatechanged() Invoked whenever an ItemEvent object is generated (a checkbox is checked, an item is selected from a choice menu, or an item is selected froma list) FocusListener interface: Implemented to receive notifications whenever a component gains or loses focus. The two methods to be overridden are focusgained() and focuslost(). The corresponding adapter class is FocusAdapter. FileDialog(Frame f, String s) - Creates a new dialog for loading files(file open dialog) attached to the frame with the specified title FileDialog(Frame f, String s, int i) - Creates a 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 FileDialog.SAVE AWT Event Listener interfaces: For every AWT event class there is a corresponding event-listener interface, which is a part of the java.awt.event package and provides the eventhandling methods. ActionListener interface: Implemented by a class that handles an action event. The method actionperformed() must be overridden by the implementing class. focusgained() focuslost() Invoked whenever a component gains keyboard focus Invoked whenever a component loses keyboard focus KeyListener interface: Implemented to handle key events. Each of the three methods keypressed(), keyreleased(), keytyped() receives a KeyEvent object when a key event is generated. KeyPressed() keyreleased() Invoked whenever a key is pressed Invoked whenever a key is released 36
10 keytyped() Invoked whenever a key is typed MouseListener interface: Implemented by a class handling mouse events. It comprises of five methods invoked when a MouseEvent object is generated. Its corresponding adapter class is the MouseAdapter class. mouseclicked() mouseentered() mouseexited() Invoked when mouse is clicked on a component Invoked when mouse enters a component Invoked when mouse exits a component windowdeactivated() windowiconified() windowdeiconified() Invoked when the window is no longer the active window i.e. the window can no longer receive keyboard events Invoked when a normal window is minimized Invoked when a minimized window is changed to normal state java.sql.driver interface: Implemented by every driver class. s of the Driver interface: mousepressed() mousereleased() Invoked when mouse button is pressed on a component Invoked when mouse button is released on a component acceptsurl() connect() Returns a Boolean value indicating whether the driver can open a connection to the specified URL Tries to make a database connection to the specified URL MouseMotionListener interface: Implemented by a class for receiving mouse-motion events. Consists of two methods mousedragged() and mousemoved(), which is invoked when a MouseEvent object is generated. MouseMotionAdapter is its corresponding adapter class. getmajorversion() getminorversion() Returns the driver s major version number Returns the driver s minor version number mousedragged() Invoked when the mouse is pressed on a component and dragged jdbccompliant() JDBC compliant driver Tests whether the driver is a genuine java.sql.connection interface: Represents a session with a specific database. SQL statements are executed within a session and the results are returned. mousemoved() Invoked when mouse is moved over a component s of the Connection interface: WindowListener interface: Implemented by a class to receive window events. It consists of seven different methods to handle the different kinds of window events, which are invoked when a WindowEvent object is generated. Its corresponding adapter class is the WindowAdapter class. windowopened() windowclosing() windowclosed() windowactivated() Invoked when the window is made visible for the first time Invoked when the user attempts to close the window from the Windows system menu Invoked when the window has been closed as a result of calling the dispose() method Invoked when the window is made active i.e. the window can receive keyboard events Close() commit() createstatement() getmetadata() isreadonly() preparecall() Immediately releases the database and JDBC resources Makes all changes since the last commit/rollback permanent, and releases the database locks held by the connection Creates and returns a Statement object. It is used for sending SQL statements to be executed on the database Returns a DatabaseMetaData object that represents metadata about the database Checks whether the connection is a read-only connection Creates and returns a Callable Statement object, 39 4
11 preparecall() preparestatement() rollback() setautocommit() Creates and returns a CallableStatement object (used for calling database stored procedures) Creates and returns a PreparedStatement object (used for sending precompiled SQL statements to the database) Discards all the changes made since the last commit/rollback and releases database locks held by the connection 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. s of the DriverManager class: 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 registerdriver() setlogintimeout() getdrivers() getdriver() Registers the specified driver with the DriverManager Sets the maximum number of seconds a driver can wait when attempting to connect to the database Returns an enumeration of all the drivers installed on the system Returns a Driver object that supports connection through a specified URL
Pemrograman Dasar. Basic Elements Of Java
Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle
An Overview of Java. overview-1
An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2
Chapter 1 Java Program Design and Development
presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented
INPUT AND OUTPUT STREAMS
INPUT AND OUTPUT The Java Platform supports different kinds of information sources and information sinks. A program may get data from an information source which may be a file on disk, a network connection,
java.applet Reference
18 In this chapter: Introduction to the Reference Chapters Package diagrams java.applet Reference Introduction to the Reference Chapters The preceding seventeen chapters cover just about all there is to
core 2 Handling Mouse and Keyboard Events
core Web programming Handling Mouse and Keyboard Events 1 2001-2003 Marty Hall, Larry Brown http:// Agenda General event-handling strategy Handling events with separate listeners Handling events by implementing
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.
http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral
Mouse Event Handling (cont.)
GUI Components: Part II Mouse Event Handling (cont.) Each mouse event-handling method receives a MouseEvent object that contains information about the mouse event that occurred, including the x- and y-coordinates
Fundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
GUI Components: Part 2
GUI Components: Part 2 JComboBox and Using an Anonymous Inner Class for Event Handling A combo box (or drop-down list) enables the user to select one item from a list. Combo boxes are implemented with
CS 335 Lecture 06 Java Programming GUI and Swing
CS 335 Lecture 06 Java Programming GUI and Swing Java: Basic GUI Components Swing component overview Event handling Inner classes and anonymous inner classes Examples and various components Layouts Panels
Java Mouse and Keyboard Methods
7 Java Mouse and Keyboard Methods 7.1 Introduction The previous chapters have discussed the Java programming language. This chapter investigates event-driven programs. Traditional methods of programming
GUI Event-Driven Programming
GUI Event-Driven Programming CSE 331 Software Design & Implementation Slides contain content by Hal Perkins and Michael Hotan 1 Outline User events and callbacks Event objects Event listeners Registering
AP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
Java Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt
core. 2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Volume I - Fundamentals Seventh Edition CAY S. HORSTMANN GARY
Syllabus for CS 134 Java Programming
- Java Programming Syllabus Page 1 Syllabus for CS 134 Java Programming Computer Science Course Catalog 2000-2001: This course is an introduction to objectoriented programming using the Java language.
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
Java (12 Weeks) Introduction to Java Programming Language
Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short
The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)
Binary I/O streams (ascii, 8 bits) InputStream OutputStream The Java I/O System The decorator design pattern Character I/O streams (Unicode, 16 bits) Reader Writer Comparing Binary I/O to Character I/O
Chapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk
CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling
Java Programming Fundamentals
Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few
Introduction to Java Applets (Deitel chapter 3)
Introduction to Java Applets (Deitel chapter 3) 1 2 Plan Introduction Sample Applets from the Java 2 Software Development Kit Simple Java Applet: Drawing a String Drawing Strings and Lines Adding Floating-Point
Introduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
CS 1302 Ch 19, Binary I/O
CS 1302 Ch 19, Binary I/O Sections Pages Review Questions Programming Exercises 19.1-19.4.1, 19.6-19.6 710-715, 724-729 Liang s Site any Sections 19.1 Introduction 1. An important part of programming is
TABLE OF CONTENTS...2 INTRODUCTION...3 APPLETS AND APPLICATIONS...3 JAVABEANS...4 EXCEPTION HANDLING...5 JAVA DATABASE CONNECTIVITY (JDBC)...
Advanced Features Trenton Computer Festival May 1 sstt & 2 n d,, 2004 Michael P.. Redlich Senior Research Technician ExxonMobil Research & Engineering [email protected] Table of Contents
Java from a C perspective. Plan
Java from a C perspective Cristian Bogdan 2D2052/ingint04 Plan Objectives and Book Packages and Classes Types and memory allocation Syntax and C-like Statements Object Orientation (minimal intro) Exceptions,
Building a Multi-Threaded Web Server
Building a Multi-Threaded Web Server In this lab we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous
Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:
Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of
MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC
MyOra 3.0 SQL Tool for Oracle User Guide Jayam Systems, LLC Contents Features... 4 Connecting to the Database... 5 Login... 5 Login History... 6 Connection Indicator... 6 Closing the Connection... 7 SQL
C++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
How To Write A Program For The Web In Java (Java)
21 Applets and Web Programming As noted in Chapter 2, although Java is a general purpose programming language that can be used to create almost any type of computer program, much of the excitement surrounding
Tutorial Reference Manual. Java WireFusion 4.1
Tutorial Reference Manual Java WireFusion 4.1 Contents INTRODUCTION...1 About this Manual...2 REQUIREMENTS...3 User Requirements...3 System Requirements...3 SHORTCUTS...4 DEVELOPMENT ENVIRONMENT...5 Menu
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
Data Tool Platform SQL Development Tools
Data Tool Platform SQL Development Tools ekapner Contents Setting SQL Development Preferences...5 Execution Plan View Options Preferences...5 General Preferences...5 Label Decorations Preferences...6
The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0
The following applies to all exams: Once exam vouchers are purchased you have up to one year from the date of purchase to use it. Each voucher is valid for one exam and may only be used at an Authorized
Visual Basic 2010 Essentials
Visual Basic 2010 Essentials Visual Basic 2010 Essentials First Edition 2010 Payload Media. This ebook is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited.
2 ASCII TABLE (DOS) 3 ASCII TABLE (Window)
1 ASCII TABLE 2 ASCII TABLE (DOS) 3 ASCII TABLE (Window) 4 Keyboard Codes The Diagram below shows the codes that are returned when a key is pressed. For example, pressing a would return 0x61. If it is
GUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012
GUIs with Swing Principles of Software Construction: Objects, Design, and Concurrency Jonathan Aldrich and Charlie Garrod Fall 2012 Slides copyright 2012 by Jeffrey Eppinger, Jonathan Aldrich, William
public static void main(string[] args) { System.out.println("hello, world"); } }
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
java.util.scanner Here are some of the many features of Scanner objects. Some Features of java.util.scanner
java.util.scanner java.util.scanner is a class in the Java API used to create a Scanner object, an extremely versatile object that you can use to input alphanumeric characters from several input sources
Crash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
Appendix K Introduction to Microsoft Visual C++ 6.0
Appendix K Introduction to Microsoft Visual C++ 6.0 This appendix serves as a quick reference for performing the following operations using the Microsoft Visual C++ integrated development environment (IDE):
WRITING DATA TO A BINARY FILE
WRITING DATA TO A BINARY FILE TEXT FILES VS. BINARY FILES Up to now, we have looked at how to write and read characters to and from a text file. Text files are files that contain sequences of characters.
Windows PowerShell Essentials
Windows PowerShell Essentials Windows PowerShell Essentials Edition 1.0. This ebook is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited. All rights
What is an I/O Stream?
Java I/O Stream 1 Topics What is an I/O stream? Types of Streams Stream class hierarchy Control flow of an I/O operation using Streams Byte streams Character streams Buffered streams Standard I/O streams
Event-Driven Programming
Event-Driven Programming Lecture 4 Jenny Walter Fall 2008 Simple Graphics Program import acm.graphics.*; import java.awt.*; import acm.program.*; public class Circle extends GraphicsProgram { public void
Essentials of the Java(TM) Programming Language, Part 1
Essentials of the Java(TM) Programming Language, Part 1 http://developer.java.sun.com/developer...ining/programming/basicjava1/index.html Training Index Essentials of the Java TM Programming Language:
Java CPD (I) Frans Coenen Department of Computer Science
Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials
Designing and Implementing Forms 34
C H A P T E R 34 Designing and Implementing Forms 34 You can add forms to your site to collect information from site visitors; for example, to survey potential customers, conduct credit-card transactions,
Web Development and Core Java Lab Manual V th Semester
Web Development and Core Java Lab Manual V th Semester DEPT. OF COMPUTER SCIENCE AND ENGINEERING Prepared By: Kuldeep Yadav Assistant Professor, Department of Computer Science and Engineering, RPS College
STATGRAPHICS Online. Statistical Analysis and Data Visualization System. Revised 6/21/2012. Copyright 2012 by StatPoint Technologies, Inc.
STATGRAPHICS Online Statistical Analysis and Data Visualization System Revised 6/21/2012 Copyright 2012 by StatPoint Technologies, Inc. All rights reserved. Table of Contents Introduction... 1 Chapter
Interaction: Mouse and Keyboard DECO1012
Interaction: Mouse and Keyboard DECO1012 Interaction Design Interaction Design is the research and development of the ways that humans and computers interact. It includes the research and development of
http://netbeans.org/kb/docs/java/gui-functionality.html?print=yes
Page 1 of 6 Introduction to GUI Building Contributed by Saleem Gul and Tomas Pavek, maintained by Ruth Kusterer and Irina Filippova This beginner tutorial teaches you how to create a simple graphical user
Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner
1 vk» Java 7 Recipes (,\['«** - < g!p#«josh Juneau Carl Dea Freddy Guime John O'Conner Contents J Contents at a Glance About the Authors About the Technical Reviewers Acknowledgments Introduction iv xvi
MyOra 3.5. User Guide. SQL Tool for Oracle. Kris Murthy
MyOra 3.5 SQL Tool for Oracle User Guide Kris Murthy Contents Features... 4 Connecting to the Database... 5 Login... 5 Login History... 6 Connection Indicator... 6 Closing the Connection... 7 SQL Editor...
Version 1.5 Satlantic Inc.
SatCon Data Conversion Program Users Guide Version 1.5 Version: 1.5 (B) - March 09, 2011 i/i TABLE OF CONTENTS 1.0 Introduction... 1 2.0 Installation... 1 3.0 Glossary of terms... 1 4.0 Getting Started...
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything
Chapter 2: Elements of Java
Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction
CS 111 Classes I 1. Software Organization View to this point:
CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects
Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.
Scanner The Scanner class is intended to be used for input. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit. For example, suppose the input
The Basic Java Applet and JApplet
I2PUJ4 - Chapter 6 - Applets, HTML, and GUI s The Basic Java Applet and JApplet Rob Dempster [email protected] School of Computer Science University of KwaZulu-Natal Pietermaritzburg Campus I2PUJ4 - Chapter
LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development
LAB 1 Familiarization of Rational Rose Environment And UML for small Java Application Development OBJECTIVE AND BACKGROUND The purpose of this first UML lab is to familiarize programmers with Rational
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third
understand how image maps can enhance a design and make a site more interactive know how to create an image map easily with Dreamweaver
LESSON 3: ADDING IMAGE MAPS, ANIMATION, AND FORMS CREATING AN IMAGE MAP OBJECTIVES By the end of this part of the lesson you will: understand how image maps can enhance a design and make a site more interactive
How to Install Java onto your system
How to Install Java onto your system 1. In your browser enter the URL: Java SE 2. Choose: Java SE Downloads Java Platform (JDK) 7 jdk-7- windows-i586.exe. 3. Accept the License Agreement and choose the
D06 PROGRAMMING with JAVA
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch16 Files and Streams PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for
There are some important differences between an applet and a standalone Java application, including the following:
JAVA - APPLET BASICS Copyright tutorialspoint.com An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java API at its
Module One: Getting Started... 6. Opening Outlook... 6. Setting Up Outlook for the First Time... 7. Understanding the Interface...
2 CONTENTS Module One: Getting Started... 6 Opening Outlook... 6 Setting Up Outlook for the First Time... 7 Understanding the Interface...12 Using Backstage View...14 Viewing Your Inbox...15 Closing Outlook...17
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman
Here's the code for our first Applet which will display 'I love Java' as a message in a Web page
Create a Java Applet Those of you who purchased my latest book, Learn to Program with Java, know that in the book, we create a Java program designed to calculate grades for the English, Math and Science
Visual Basic Programming. An Introduction
Visual Basic Programming An Introduction Why Visual Basic? Programming for the Windows User Interface is extremely complicated. Other Graphical User Interfaces (GUI) are no better. Visual Basic provides
CaptainCasa. CaptainCasa Enterprise Client. CaptainCasa Enterprise Client. Feature Overview
Feature Overview Page 1 Technology Client Server Client-Server Communication Client Runtime Application Deployment Java Swing based (JRE 1.6), generic rich frontend client. HTML based thin frontend client
Variables, Constants, and Data Types
Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class: L&L, 2.1-2.3, App C 1 Primitive Data There are eight
Dreamweaver Tutorials Creating a Web Contact Form
Dreamweaver Tutorials This tutorial will explain how to create an online contact form. There are two pages involved: the form and the confirmation page. When a user presses the submit button on the form,
Programming with Java GUI components
Programming with Java GUI components Java includes libraries to provide multi-platform support for Graphic User Interface objects. The multi-platform aspect of this is that you can write a program on a
How to Edit Your Website
How to Edit Your Website A guide to using your Content Management System Overview 2 Accessing the CMS 2 Choosing Your Language 2 Resetting Your Password 3 Sites 4 Favorites 4 Pages 5 Creating Pages 5 Managing
Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives
Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,
Chapter 4: Website Basics
1 Chapter 4: In its most basic form, a website is a group of files stored in folders on a hard drive that is connected directly to the internet. These files include all of the items that you see on your
How to develop your own app
How to develop your own app It s important that everything on the hardware side and also on the software side of our Android-to-serial converter should be as simple as possible. We have the advantage that
Using Adobe Dreamweaver CS4 (10.0)
Getting Started Before you begin create a folder on your desktop called DreamweaverTraining This is where you will save your pages. Inside of the DreamweaverTraining folder, create another folder called
method is never called because it is automatically called by the window manager. An example of overriding the paint() method in an Applet follows:
Applets - Java Programming for the Web An applet is a Java program designed to run in a Java-enabled browser or an applet viewer. In a browser, an applet is called into execution when the APPLET HTML tag
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
Java applets. SwIG Jing He
Java applets SwIG Jing He Outline What is Java? Java Applications Java Applets Java Applets Securities Summary What is Java? Java was conceived by James Gosling at Sun Microsystems Inc. in 1991 Java is
BCA 421- Java. Tilak Maharashtra University. Bachelor of Computer Applications (BCA) 1. The Genesis of Java
Tilak Maharashtra University Bachelor of Computer Applications (BCA) BCA 421- Java 1. The Genesis of Java Creation of Java, Why it is important to Internet, characteristics of Java 2. Basics of Programming
JAVA IN A NUTSHELL O'REILLY. David Flanagan. Fifth Edition. Beijing Cambridge Farnham Köln Sebastopol Tokyo
JAVA 1i IN A NUTSHELL Fifth Edition David Flanagan O'REILLY Beijing Cambridge Farnham Köln Sebastopol Tokyo Table of Contents Preface xvii Part 1. Introducing Java 1. Introduction 1 What 1s Java? 1 The
INFORMATION BROCHURE Certificate Course in Web Design Using PHP/MySQL
INFORMATION BROCHURE OF Certificate Course in Web Design Using PHP/MySQL National Institute of Electronics & Information Technology (An Autonomous Scientific Society of Department of Information Technology,
Chapter 3. Input and output. 3.1 The System class
Chapter 3 Input and output The programs we ve looked at so far just display messages, which doesn t involve a lot of real computation. This chapter will show you how to read input from the keyboard, use
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
Chulalongkorn University International School of Engineering Department of Computer Engineering 2140105 Computer Programming Lab.
Chulalongkorn University Name International School of Engineering Student ID Department of Computer Engineering Station No. 2140105 Computer Programming Lab. Date Lab 2 Using Java API documents, command
UNIVERSITY OF CALGARY Information Technologies WEBFORMS DRUPAL 7 WEB CONTENT MANAGEMENT
UNIVERSITY OF CALGARY Information Technologies WEBFORMS DRUPAL 7 WEB CONTENT MANAGEMENT Table of Contents Creating a Webform First Steps... 1 Form Components... 2 Component Types.......4 Conditionals...
Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
