Category Archives: Java

Java Tutorial


About Java programming language! Java is an object-oriented programming language. Java is compiled and interpreted. Java programming language has the following advantages: simplicity, portability, platform independence, object orientation, high security, high performance. Java is a programming platform that includes the following features: Java programming language Compiler A virtual machine called the Java Virtual Machine(JVM) A class library Object-oriented… Read More »

Java Swing

The main classes of the swing package are: JApplet JButton JCheckBox JCheckBoxMenuItem JColorChooser JComboBox JComponent JDesktopPane JDialog JFileChooser JFormattedTextField JFrame JInternalFrame JLabel JList JMenu JMenuBar JMenuItem JOptionPane JPanel JPasswordField JPopupMenu JProgressBar JRadioButton JRadioButtonMenuItem JSlider JScrollBar JScrollPane JSeparator JTable JTextArea JTextComponent JTextField JToggleButton JTree JWindow Timer

Java AWT

The main classes of the java awt package are: BorderLayout Button Canvas Checkbox CheckboxGroup CheckboxMenuItem Choice Color Component Container Dialog Dimension FileDialog FlowLayout Font Frame Graphics GridBagLayout GridLayout Image ImageCapabilities Label List Menu MenuBar MenuComponent MenuItem Panel Point PopupMenu Scrollbar ScrollPane TextArea TextComponent TextField Toolkit Window

Java I/O Streams

Java I/O Streams Java I/O Streams are used for reading or writing information that are on an external source. Java I/O Streams allow communication between two or more threads. In Java there are two types of streams: Byte Streams Character Streams Classes that perform input and output operations are stored in the package The main classes of… Read More »

Java Exceptions

Java Exceptions Exceptions in Java represent errors that occur during execution of a program. Exception handling is used to avoid undesirable display errors, but also easier to correct any errors. To handle exceptions occurred during runtime uses: The try-catch-finally Exception thrown by method throws Exception example Try-catch-finally example public class ExceptionExample{ public static void main(String [] args){ try{… Read More »

Java Packages

Java Packages A package is a collection of classes and related interfaces. Java packages are used to facilitate finding and using classes to avoid name conflicts and to control access to classes. To use a class or call a method of a package it must be public. Package example Package 1 package Pack1; public class Class1{ String name… Read More »

Java Interface

Java Interface A Java interface is a collection of abstract methods and constant declarations. A Java class can implement one or more interfaces. An interface can extend another interface using new methods abstract. To define a java interface uses keyword interface. To implement an java interface uses keyword implements. Interface example public interface A1{ void test1(); } public… Read More »

Java Inheritance

Java Inheritance Inheritance is the process by which a Java class inherits another class content. Inheritance is done by using the keyword extends. The class that performs the extension is called subclass or derived class. A java class can inherit only one class, but can be inherited by any class. Inheritance example public class Test1{ int id =… Read More »

Java Methods

Java Methods A method defines the behavior of an object. The methods consist of modifiers, declaring a name for the method, data type that the method returns, parameters and a block of instructions that are executed when the method is executed. Modifiers can be: Access specifier: public, protected, private. One of the reserved keywords: static, abstract, final, native,… Read More »

Java Classes

Java Classes A class is a description of a set of objects and may contain one or more constructors to create objects. A class is defined by specifying instance variables, instance methods and through relationships with other classes. A Java class can be composed of: Variables Constructors Methods Classes Declare class example public class ClassName { // variables… Read More »