- 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
Karthikeya Boyini has Published 2383 Articles
karthikeya Boyini
6K+ Views
To convert double primitive type to a Double object, you need to use Double constructor.Let’s say the following is our double primitive.// double primitive double val = 23.78;To convert it to a Double object, use Double constructor.// Double object Double ob = new Double(val);Example Live Demopublic class Demo { public ... Read More
karthikeya Boyini
116 Views
The java.lang.Double.isNan() method returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.Let’s say the following are our Double values.Double val1 = new Double(3/0.); Double val2 = new Double(0/0.);Now, we will use the isNan() method to check whether the number is a NaN or not.val1.isNaN(); val2.isNaN()The following ... Read More
karthikeya Boyini
154 Views
Use the parseFloat() method in Java to convert a String to a float type.Let’s say we have the following string.String str = "111.8";Now, the Float.parseFloat() method will convert it to a float type number.float floatVal = Float.parseFloat(str);The following is the complete example with output.Example Live Demopublic class Demo { public ... Read More
karthikeya Boyini
115 Views
To check two float arrays for equality, use the Arrays.equals() method.In our example, we have the following two float arrays.float[] floatVal1 = new float[] { 3.2f, 5.5f, 5.3f }; float[] floatVal2 = new float[] { 3.2f, 5.5f, 5.3f };Let us now compare them for equality.if (Arrays.equals(floatVal1, floatVal2)) { System.out.println("Both are ... Read More
karthikeya Boyini
4K+ Views
When static keyword is used, variable or data members or functions can not be modified again. It is allocated for the lifetime of program. Static functions can be called directly by using class name.Static variables are initialized only once. Compiler persist the variable till the end of the program. Static ... Read More
karthikeya Boyini
1K+ Views
return statementThe return statement terminates the execution of function and it returns the control to the calling function. It calls the constructor as well as the destructor. It returns an integer value for “int main()”.The following is the syntax of return statement.return expression;Here, expression − The expression or any value ... Read More
karthikeya Boyini
1K+ Views
Here is an example of swapping in C language, Example Live Demo#include int main() { int a = 28, b = 8; a += b -= a = b - a; // method 1 printf("After Swapping : %d\t%d", a, b); (a ^= b), (b ^= a), ... Read More
karthikeya Boyini
304 Views
For GregorianCalendar class, import the following package.import java.util.GregorianCalendar;Create an object.GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();Now, use the following field and add() method with a negative one (-1) to display the previous day.cal.add((GregorianCalendar.DATE), -1)Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo { public static void main(String[] a) { ... Read More