All class in java.lang package

All class below is from java.lang package. If you want to use one of the class in the list, you don't need to import it into your program like other class, for example class JFrame from javax.swing package that need import statement in your program ( import javax.swing.JFrame ). This is because it will import implicitly into your program by compiler.

*******************************
Interfaces
*******************************
Appendable
CharSequence
Cloneable
Comparable
Iterable
Readable
Runnable
Thread.UncaughtExceptionHandler


*******************************
Classes
*******************************
Boolean
Byte
Character
Character.Subset
Character.UnicodeBlock
Class
ClassLoader
Compiler
Double
Enum
Float
InheritableThreadLocal
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runtime
RuntimePermission
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable
Void


*******************************
Enums
*******************************
Thread.State

*******************************
Exceptions
*******************************
ArithmeticException
ArrayIndexOutOfBoundsException
ArrayStoreException
ClassCastException
ClassNotFoundException
CloneNotSupportedException
EnumConstantNotPresentException
Exception
IllegalAccessException
IllegalArgumentException
IllegalMonitorStateException
IllegalStateException
IllegalThreadStateException
IndexOutOfBoundsException
InstantiationException
InterruptedException
NegativeArraySizeException
NoSuchFieldException
NoSuchMethodException
NullPointerException
NumberFormatException
RuntimeException
SecurityException
StringIndexOutOfBoundsException
TypeNotPresentException
UnsupportedOperationException


*******************************
Errors
*******************************
AbstractMethodError
AssertionError
ClassCircularityError
ClassFormatError
Error
ExceptionInInitializerError
IllegalAccessError
IncompatibleClassChangeError
InstantiationError
InternalError
LinkageError
NoClassDefFoundError
NoSuchFieldError
NoSuchMethodError
OutOfMemoryError
StackOverflowError
ThreadDeath
UnknownError
UnsatisfiedLinkError
UnsupportedClassVersionError
VerifyError
VirtualMachineError


*******************************
Annotation Types
*******************************
Deprecated
Override
SuppressWarnings

Why we don't import String

This is because String is from java.lang ( java.lang.String ) package. All class from java.lang package will import implicitly into your program by java compiler.

Click here to see other class in java.lang package

Combine String

Complete source code below will show you, how to combine two String using + symbol and concat() method from String class.

**************************************************************************
COMPLETE SOURCE CODE FOR : CombineString.java
**************************************************************************


public class CombineString
{
public static void main(String[]args)
{
String a="Hello ";
String b="world";

//First Technique : Using + symbol
String c=a+b;

//Second Technique : Using concat() method from String class
String d=a.concat(b);

//Now we will print result. It should be same.
System.out.println(c);
System.out.println(d);
}
}


**************************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************************

Determine character location in a String

Now, i will share with you, how to determine location of a character in a String. Ok...firstly you must know location of a character in a String is determine using 'index'. Index for first character in a String is equal to 0 and each character include white space after that will add 1.

Note : Character location = index

String a="Hello dude";

Below is a list all character in String above with it's index.

H - 0
e - 1
l - 2
l - 3
o - 4
white space - 5
d - 6
u - 7
d - 8
e - 9

Draw grid on JFrame

Complete source code below will show you, how to draw grid on a JFrame.

****************************************************************************
COMPLETE SOURCE CODE FOR : DrawGridOnJFrame.java
****************************************************************************


import javax.swing.JFrame;

import java.awt.Graphics;

public class DrawGridOnJFrame extends JFrame
{
//Constructor
public DrawGridOnJFrame()
{
//Set JFrame title to ( Draw grid on JFrame )
setTitle("Draw grid on JFrame");

//Set JFrame size to :
//Width : 400 pixels
//Height : 400 pixels
setSize(400,400);

//Set JFrame default close operation
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Make JFrame visible
setVisible(true);
}


/**
*To draw grid line on JFrame we will override it's paint method.
*We will draw grid with size 10 pixels width and 10 pixels height for each grid box
**/
public void paint(Graphics g)
{
//Override paint method in superclass
super.paint(g);

//Get current JFrame width
int frameWidth=getSize().width;

//Get current JFrame height
int frameHeight=getSize().height;

int temp=0;

//Draw vertical grid line with spacing between each line equal to 10 pixels
while(temp<frameWidth)
{
temp=temp+10;
g.drawLine(temp,0,temp,frameHeight);
}

temp=0;

//Draw horizontal grid line with spacing between each line equal to 10 pixels
while(temp<frameHeight)
{
temp=temp+10;
g.drawLine(0,temp,frameWidth,temp);
}
}

//Main method
public static void main(String[]args)
{
DrawGridOnJFrame dgojf=new DrawGridOnJFrame();
}
}


****************************************************************************
JUST COMPILE AND EXECUTE IT
****************************************************************************

Convert String to lowercase

Complete source code below will show you, how to convert a String to lowercase.

**************************************************************************
COMPLETE SOURCE CODE FOR : ConvertStringToLowercase.java
**************************************************************************


public class ConvertStringToLowercase
{
public static void main(String[]args)
{
//Create a String
String a="WELCOME TO JAVA2EVERYONE!";

//Convert created String to lowercase
a=a.toLowerCase();

//Print the String
System.out.println(a);
}
}


**************************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************************

RELAXING NATURE VIDEO