Java comments, as name suggests, are notes you write between the programs for various reasons. For example, you may write comments to – write information or explanation about the variable, method, class or any statement. write text to be available in Java docs. hide program code for specific time, etc. Types of Java Comments There […]
As term suggest, a variable is whose value can vary during the runtime. In Java, a variable is a named reference to a memory area where value of the variable is stored. A variable declaration has following syntax: [data_type] [variable_name] = [variable_value]; data_type – refer to type of information stored in memory area. variable_name – […]
JDK, JRE and JVM is very common words when developers talk about java applications and their development environments. Let’s find out the differeneces between these words.
Using programming, we cannot change the way these floating point numbers are stored or computed. So we have to adapt a solution where we agree that a determine the differences in both values which we can tolerate and still consider the numbers equal. This agreed upon difference in values is called the threshold.
Use given syntax examples for setting CLASSPATH for any java application runtime, in windows and linux environments.
Java maintains a set of system properties for its operations. Each java system property is a key-value (String-String) pair such as “java.version”=”1.7.0_09“. You can retrieve all the system properties via System.getProperties() or you can also retrieve individual property via System.getProperty(key). Please note that Access to system properties can be restricted by the Java security manager […]
The normal import declaration imports classes from packages, so that they can be used without package reference. Similarly the static import declaration imports static members from classes and allowing them to be used without class reference. A static import declaration also comes in two flavors: single-static import and static-import-on-demand. A single-static import declaration imports one […]
Classes are the basic units of programming in the object-oriented paradigm. In this tutorial, we will look into some basic yet important stuffs, you need to know, while writing a class in java. In Java, classes are used as templates to create objects. Let’s discuss how to define a class. A class in Java may […]
After learning break statements, lets quickly recap about another important keyword “continue” in java. In one sentence, the continue statement skips the current iteration of a for loop, while loop, or do-while loop. Let’s go deeper into continue statements. A continue statement can only be used inside the for-loop, while-loop, and do-while statements. There are […]
We have already learned about primitives, operators and control statements like if-else, for loop, switch statement and while loop. Now let’s learn about another important keyword i.e. break statement. A break statement is used to exit from a block. There are two forms of the break Statements: Unlabeled break statement Labeled break statement Unlabeled break […]
During learning “While Loop” we saw that it continually executes a block of statements while a particular condition is true. The difference between do-while loop and while loop is that do-while evaluates its expression at the bottom of the loop instead of the top. Therefore, the statements within the do block are always executed at […]
The while statement or loop continually executes a block of statements while a particular condition is true. Its syntax can be expressed as: The condition-expression must be a boolean expression and the statement can be a simple statement or a block statement. If the expression evaluates to true, the while statement executes the statement(s) in […]
In previous tutorial, we learned about for loop in java. Java 5 introduced an foreach loop, which is called a enhanced foreach loop. It is used for iterating over elements of arrays and collections. Java foreach loop syntax The general syntax for a for-each loop is as follows: Java foreach loop – array For example, […]
The for statement provides a compact way to iterate over a range of values. Programmers often refer to it as the “for loop” because of the way in which it repeatedly loops until a particular condition is satisfied. The general form of the for statement can be expressed as follows: Here : The initialization expression […]
As if-else statement tells your program to execute a certain section of code only if a particular test evaluates to true or false, the switch statement can have a number of possible execution paths. A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types, the String […]
The if-then statement is the most basic of all the control flow statements. It tells your program to execute a certain section of code only if a particular test evaluates to true. The format of an if-else statement is : if (condition) statement1 else statement2 The condition must be a Boolean expression. That is, it […]
A block statement is a sequence of zero or more statements enclosed in braces. A block statement is generally used to group together several statements, so they can be used in a situation that requires you to use a single statement. In some situations, you can use only one statement. If you want to use […]
A statement specifies an action in a Java program, such as assigning the sum of x and y to z, printing a message to the standard output, writing data to a file, etc. Statements in Java can be broadly classified into three categories: Declaration statement Expression statement Control flow statement Declaration Statement A declaration statement […]
In this post, we will learn about available operators in java and their example usages. We will also try to understand when to use them and what to expect in result. Table of Contents What Is an Operator? Assignment Operator (=) Arithmetic Operators Unary Arithmetic Operators Binary Arithmetic Operators String Concatenation Operator (+) Relational Operators […]
You must have heard these terms Little-Endian and Big-Endian many times in your engineering course. Let’s quickly recap the concept behind these words. These two terms are related to the direction of bytes in a word within CPU architecture. Computer memory is referenced by addresses that are positive integers. It is “natural” to store numbers […]