- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4338 Articles for Java 8
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
851 Views
Creating an exact copy of an existing object in the memory is known as cloning.The clone() method of the class java.lang.Object accepts an object as a parameter, creates and returns a copy of it (clones).In order to use this method, you need to make sure that your class implements the Cloneable interface.Example Live Demoimport java.util.Scanner; public class CloneExample implements Cloneable { private String name; private int age; public CloneExample(String name, int age){ this.name = name; this.age = age; } public void displayData(){ System.out.println("Name : "+this.name); ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
2K+ Views
Using loops in programming languages we can execute a set of statements repeatedly. Java provides various loops namely while loop, for loop and the do while loop.The for statement contains an initialization statement, a condition and, an increment or decrement operation.Initializing statement − The initialization determines the starting value of the loop.Condition − The condition in for loop is a statement returning a boolean value. This condition determines the exit value of the loop. It is executed before the statements of the loop.Increment and decrement − Using this the loop will be incremented or decremented to the next value.After initializing ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
1K+ Views
The increment operator increments the value of the operand by 1 and the decrement operator decrements the value of the operand by 1. We use these operators to increment or, decrement the values of the loop after executing the statements on a value.Example Live Demopublic class ForLoopExample { public static void main(String args[]) { //Printing the numbers 1 to 10 for(int i = 1; i=1; i--) { System.out.print(" "+i); } } }Output1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
3K+ Views
Java provides two operators namely ++ and --, to increment and decrement values by 1 respectively.There are two variants of these operators −Pre-increment/decrement − This form, increments/decrements the value first, and then performs the specified operation.ExampleIn the following example, the initial value of the variable i is 5. We are printing the incremented value of it using the pre increment operator.Since we are using the pre increment operator, the value of i is incremented then printed. Live Demopublic class ForLoopExample { public static void main(String args[]) { int i = 5; System.out.println(++i); ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
882 Views
Keywords − Keywords in Java convey a special meaning to the compiler therefore, these cannot be used as identifiers. Java provides a set of 50 keywords.abstractcontinuefornewswitchassertdefaultgotopackagesynchronizedbooleandoifprivatethisbreakdoubleimplementsprotectedthrowbyteelseimportpublicthrowscaseenuminstanceofreturntransientcatchextendsintshorttrycharfinalinterfacestaticvoidclassfinallylongstrictfpvolatileconstfloatnativesuperwhileReserved words − Among the list of key words list mentioned above the key words goto and const are currently not in use. They are reserved words (for the future use).The true false and null − True, false and null represents certain values in Java, they are used as literals. They are not considered as keywords.Still, you cannot use them as identifiers in Java if you try to do so, a compile time error will ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
94 Views
The instanceof operator in Java is used to find whether a reference is an instance of a Type i.e. class or an interface.Example Live Demopublic class InstanceOfExample { public static void main(String args[]) { String str = "hello"; boolean bool = str instanceof String; System.out.println(bool); } }OutputtrueLegal operands of the instanceof operatorThe following are the only legal operands of the instanceof operator −Left operand − It must be a reference representing an object.Right operand − It must be the name of Java class or, interface.Except these two if you use ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
2K+ Views
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.Syntaxswitch(expression) { case value : // Statements break; case value : // Statements break; // You can have any number of case statements. default : // Statements }Rules to be followedWhile working with a switch statement keep the following points in mind −We must only use int, ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
2K+ Views
In general, data is stored in a computer in the form of bits (1 or, 0). There are various coding schemes available specifying the set of bytes represented by each character.ASCII − Stands for American Standards Code for Information Interchange. It is developed by American standards association and is the mostly used coding system. It represents characters using 7 bits and has includes 128 characters: upper and lowercase Latin alphabet, the numbers 0-9, and some extra characters).Unicode (UTF) − Stands for Unicode Translation Format. It is developed by The Unicode Consortium. if you want to create documents that use characters ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
3K+ Views
Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Casting in JavaConverting one primitive data type into another is known as type casting. There are two types of casting −Widening− Converting a lower datatype to a higher datatype is known as widening. It is done implicitly.Narrowing− Converting a higher datatype to a lower datatype is known as narrowing. You need to do it explicitly using the cast operator (“( )”).Casting double to byteDouble is a higher datatype compared ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
712 Views
Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Casting in JavaConverting one primitive data type into another is known as type casting. There are two types of casting −Widening− Converting a lower datatype to a higher datatype is known as widening. It is done implicitly.Narrowing− Converting a higher datatype to a lower datatype is known as narrowing. You need to do it explicitly using the cast operator (“( )”).For every primitive variable a wrapper class is available, ... Read More