Knowing the Temp Location in Your Environment
You may want to know the temp location in your environment to use it for some purpose during the execution of the program. Here is the code to help. public
You may want to know the temp location in your environment to use it for some purpose during the execution of the program. Here is the code to help. public
The method below does nothing because the returned Date is exactly the same with the input value. Always remember that the Date does not carry time zone information, it is
Easily find the end of file that you are processing. Scanner again has a easier way of doing it. import java.util.*;import java.io.*;public class EndOfFile { public static void main(String args[])
public class UsingLangDotMath {    final int TWENTY_SEVEN = 27;       public static void main(String args[])    {       UsingLangDotMath usingLangDotMath = new UsingLangDotMath();       usingLangDotMath.proceed();    }       private void proceed()    {       System.out.println(“Cube root of 27: ” + Math.cbrt(TWENTY_SEVEN));       System.out.println(“Trigonometric sine: ” + Math.sin(TWENTY_SEVEN));       System.out.println(“Trigonometric cosine: ” + Math.cos(TWENTY_SEVEN));       System.out.println(“Trigonometric tangent: ” + Math.tan(TWENTY_SEVEN));          } } /* Expected output: [root@mypc]# java UsingLangDotMath Cube root of 27: 3.0 Trigonometric sine: 0.956375928404503 Trigonometric cosine: -0.2921388087338362 Trigonometric tangent: -3.273703800428119 */
Did you know that execution of a Java program will continue only when there is at least one user thread running? In cases in which there are no user threads,
Map map = new HashMap(collection.size());for (Object obj : collection) { map.put(obj.key, obj.value);} The code above wants to make sure that the HashMap doesn’t need to be resized, so its sets
Ever wanted to find a boolean that is available as part of the input string? The following code snippet helps you do it quickly. import java.util.*;public class ScannerUtils { public
The code below catches the exception to write out a log statement and then re-throws the same exception. It is recommended to let the caller decide if the message should
Avoiding null pointer exceptions is a good programming practice. However, simple things such as string comparison can also lead to null pointer exceptions. Considering the following: You have a constant