- 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)
426 Views
To find the angles of a triangle we can use sin/cosine rules according to cosine rule −cos A = (b^2 + c^2 - a^2)/2bcwhere A, B , C are the vertices and a, b, c are the sides of the given triangle then, angles of the triangle when the sides a, b, c given are −angleAtA = acos((b^2 + c^2 - a^2)/(2bc)) angleAtB = acos((a^2 + c^2 - b^2)/(2ac)) angleAtC = acos((a^2 + b^2 - c^2)/(2ab))
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
2K+ Views
In Java arrays are the reference types which stores multiple elements of the same datatype. You can create an array just like an object using the new keyword −type[] reference = new type[10];or, directly using the flower brackets ({}).int [] myArray = {10, 20, 30, 40, 50}When you create instance variables in Java you need to initialize them, else the compiler will initialize on your behalf with default values.Similarly, if you create an array as instance variable, you need to initialize it else the compiler initializes with default values which are −Integer − 0Byte − 0Float − 0.0Boolean − falseString/Object ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
1K+ Views
Whenever you inherit a superclass a copy of superclass’s members is created at the subclass and you using its object you can access the superclass members.If the superclass and the subclass have instance variable of same name, if you access it using the subclass object, the instance variables of the subclass hides the instance variables of the superclass irrespective of the types. This mechanism is known as field hiding or, instance variable hiding.But, since it makes code complicated field hiding is not recommended.ExampleIn the following example we have two classes Super and Sub one extending the other. They both have ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
3K+ Views
To compile a program, you doesn’t really need a main method in your program. But, while execution JVM searches for the main method. In the Java the main method is the entry point Whenever you execute a program in Java JVM searches for the main method and starts executing from it.The main method must be public, static, with return type void, and a String array as argument.public static int main(String[] args){ }You can write a program without defining a main it gets compiled without compilation errors. But when you execute it a run time error is generated saying “Main method ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
5K+ Views
You can convert an object array to an integer array in one of the following ways −By copying each element from integer array to object array −Exampleimport java.util.Arrays; public class ObjectArrayToStringArray { public static void main(String args[]){ Object[] objArray = {21, 58, 69, 33, 65}; int length = objArray.length; int intArray[] = new int[length]; for(int i=0; i
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
2K+ 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).Type Casting/type conversion −Converting one primitive datatype into another is known as type casting (type conversion) in Java. You can cast the primitive datatypes in two ways namely, Widening and, Narrowing.Narrowing − Converting a higher datatype to a lower datatype is known as narrowing. In this case the casting/conversion is not done automatically, you need to convert explicitly using the cast operator “( )” explicitly. Therefore, it is known ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
2K+ 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).Type Casting/type conversion − Converting one primitive datatype into another is known as type casting (type conversion) in Java. You can cast the primitive datatypes in two ways namely, Widening and, Narrowing.Widening − Converting a lower datatype to a higher datatype is known as widening. In this case the casting/conversion is done automatically therefore, it is known as implicit type casting. In this case both datatypes should be compatible ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
1K+ 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.Exampleimport java.util.Scanner; public class TypeCastingExample { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter an integer value: "); int i = sc.nextInt(); long num = i; System.out.println("Value of the given integer: "+num); } }OutputEnter an integer ... Read More
![Venkata Sai](https://www.tutorialspoint.com/assets/profiles/119961/profile/60_3780012-1641548375.png)
6K+ 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