Browsed by
Category: Java

Date Converter for Different Timezone and Formats

Date Converter for Different Timezone and Formats

Convert Date from one timezone to another without hassle. Covert a different format to different format. Features:- 1. Easy to use. 2. Free of cost. 3. Lightweight. 4. Pure Java tool. If you want to calculate your age or want to know how much younger or older your friend than you, Have a date in a different timezone and want to know the time in your timezone or what time in different timezone now. All this is just one download…

Read More Read More

Convert Amount In Words

Convert Amount In Words

A simple problem is to convert the given number into words for receipt or other bills related usage. import java.util.*; public class AmountInWords { private static String amount; private static int num; private static String[] units = { “”, ” One”, ” Two”, ” Three”, ” Four”, ” Five”, ” Six”, ” Seven”, ” Eight”, ” Nine” }; private static String[] teen = { ” Ten”, ” Eleven”, ” Twelve”, ” Thirteen”, ” Fourteen”, ” Fifteen”, ” Sixteen”, ” Seventeen”,…

Read More Read More

Environment Variables In Java

Environment Variables In Java

  Environment Variables  are variables that are added in any Operating system that can be accessed from anywhere in OS without using the complete(Real) location.   In a java Application System.getenv(); is used to find out the system environment variables Example:- import java.util.Map; public class EnvMap { public static void main (String[] args) { Map<String, String> env = System.getenv(); for (String envName : env.keySet()) { System.out.format(“%s=%s%n”, envName, env.get(envName)); } } }  

Security Manager in Java

Security Manager in Java

A security manager is an object that is used to check whether the operation we want to perform is not violating the security policy of the operating system. Sometimes we want to perform any operation and get an exception Exception in thread “AWT-EventQueue-1” java.security.AccessControlException: access denied (java.io.FilePermission characteroutput.txt write) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkWrite(SecurityManager.java:962) at java.io.FileOutputStream.<init>(FileOutputStream.java:169) at java.io.FileOutputStream.<init>(FileOutputStream.java:70) at java.io.FileWriter.<init>(FileWriter.java:46) To Prevent this exception we can use SecurityManager class to check for the permission before performing an operation….

Read More Read More

System Properties in java

System Properties in java

There are various system properties that we can use in our programs to perform some action or access some file.There are some commonly used properties.   Key Meaning “file.separator” Character that separates components of a file path. This is “/” on UNIX and “” on Windows. “java.class.path” Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property. “java.home” Installation directory for Java Runtime Environment (JRE) “java.vendor” JRE…

Read More Read More

strictfp Keyword in java

strictfp Keyword in java

In java  strictfp   is used to strict all the calculations of  to strictly follow the strict floating point calculations in all platforms.   It can be used with class , interfaces and non-abstract methods. If used with the method then it ensures all the calculations inside that method must follow floating point math. When used with the class then it ensures all calculations inside that class must follow floating point math. Compile-time constant expressions must always use strict floating-point behavior…

Read More Read More

JAVA Standard Edition 5.0

JAVA Standard Edition 5.0

JAVA 5.0 ( also known as Standard Edition 5.0 or J2SE 5 or J2SE 1.5) :-   Codename:- TIGER 1. Initially released in September 2004. 2. Has 3200+ classes and interfaces. 3. Introduced several updates and improvements Annotations:- Anotations wrere used to provide meta-data for the programs so that it can be easily understand for metadata-aware programs. Generics:-Generics are used to provide types of object belonging to collections. So that type safety cab be gauranteed at compile time. Autoboxing :- Autoboxing is…

Read More Read More

Jagged Array in Java

Jagged Array in Java

Java support Jagged Arrays. You can have a different length for each column do not need to have same no of the column for all rows. Example:- public class JaggedArray { public static void main(String ar[]) { int[][] a=new int[2][]; a[0]=new int[2]; a[1]=new int[4]; a[0][0]=1; a[0][1]=12; a[1][0]=10; a[1][1]=3; a[1][2]=12; a[1][3]=13; System.out.println(“length-“+a.length); for (int i = 0; i < a.length; i++) { for (int k = 0; k < a[i].length; k++) { System.out.print(a[i][k]+” , “); } System.out.println(“”); } } } Output:- length-2…

Read More Read More

Varargs in java (Passing variable no of arguments in java method)

Varargs in java (Passing variable no of arguments in java method)

After J2SE 5.0 java supports passing of variable arguments in a method that u don’t need to fix the no of arguments at the time of defining the method. The compiler automatically converts the arguments in the form of an array so u can access all the arguments at runtime. Example:- public class Varargs { public static void main(String[] args) { Varargs var=new Varargs(); var.show(“Ankit” , “Singh” , “Katiyar”); var.show(“facebook.com””,”ankitkatiyar91″); } public void show(String… arg) { for(int i=0;i<arg.length;i++)  { System.out.println(arg[i]);…

Read More Read More

External garbage collection in java

External garbage collection in java

In java garbage collection is internally implemented. For it, JVM(Java Virtual Machine) uses a Class java.lang.Runtime. The JVM’s heap stores all objects created by an executing Java program. Objects are created by Java’s “new” operator, and memory for new objects is allocated on the heap at runtime. Garbage collection is the process of automatically freeing objects that are no longer referenced by the program. This frees the programmer from having to keep track of when to free allocated memory, thereby…

Read More Read More