A loop statement allows us to execute a statement or group of statements multiple times Loop & Description while loop: Repeats a statement while a given condition is true. for loop: Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable. do…while loop: it tests the condition at the […]
Java
Java Modifier Types
Modifier Types you add to those definitions to change their meanings. Java language has a wide variety of modifiers the following: Access Control Modifiers Non-Access Modifiers Example: public class className { // … } private boolean myFlag; static final double weeks = 12.5; protected static final int BOXWIDTH = 52; public static void main(String[] arguments) […]
Java Variable Types
Following are examples of variable declaration and initialization in Java. Example: int x, y, z; // Declares three ints, x, y, and z. int x = 10, y = 25; // Example of initialization byte Y = 24; // initializes a byte type variable Y. double pi = 3.14159; // declares and assigns a value […]
Java Object and Classes
Object − Objects have states and behaviors. Example: A cat has states – color, name, breed as well as behaviors – wagging the tail, mau-mau, eating. An object is an instance of a class. Class – A class can be defined as a template/blueprint that describes the behavior/state that the object of its type support. […]
JAVA Basic Syntax
In this tutorial we discuss do class, object, methods, and instance variables mean. Java Program Example Let us look at a simple code that will print the words Hello Java. public class JavaProgramExample { /* This is my first java program. * This will print ‘Hello Java’ as the output */ public static void main(String […]
JAVA Installation
In this post, we will discuss how to install and configure java in pc or laptop. Installation setup JAVA Java SE is freely available from the link Download Java. You can download a version based on your operating system. Follow this setup for Windows. When your complete download run the .exe to install Java on […]
Java Introduction
Java programming language is very easy to learn. More than 3 billion devices run Java. Java is used to develop apps for Google’s Android OS, various Desktop Applications, such as media players, antivirus programs, Web Applications, Enterprise Applications (i.e. banking), and many more! The main Method the main method must be identical to this signature: […]
Constants, Variables, Data Types in Java
When working with computers, either for something as simple as writing a college paper or as complex as solving quantum theory equations, the single most important thing for the computer to do is deal with Data. Data to a computer can be numbers, characters or simply values. Like any other programming languages, Java supports its […]
Assertions in Java
In this post, you will learn to: State the use of assert statement. Explain implementation of assertion in code. Explain the use of internal invariants. State the use of control-flow invariants. Explain PreCondition, PostCondition, and Class Invariants Using the ‘assert’ Statement An assertion allows testing the correctness of any assumptions that have been made about […]
User-defined Exceptions in Java
In this post, you will learn to: Explain user-defined exceptions. Explain implementation of an user-defined exceptions. Explain handling and throwing of user-defined exceptions. Exception chaining. User-defined Exceptions User-defined exceptions are custom exceptions. These exceptions are created when predefined exceptions are not sufficient to handle situations specific to an application. User-defined exception classes are subclassed from […]