Convert String to uppercase

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

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


public class ConvertStringToUppercase
{
public static void main(String[]args)
{
//Create a String
String a="Hi everybody!";

//Convert created String to uppercase
a=a.toUpperCase();

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


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

Create mutable String

In java when you create a String, it's mean you create an immutable String. You cannot change it, after you create it. Complete source code below will show you, how to create a mutable String using StringBuffer class.

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


public class CreateMutableString
{
public static void main(String[]args)
{
//Create a mutable String
StringBuffer a=new StringBuffer("Hi everyone");

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


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

String tip from API

Strings are constant, their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared.

Get character from String

Complete source code below will show you, how to get character from a String in java.

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


public class GetCharacterFromString
{
public static void main(String[]args)
{
//Create a String that will be use to get character from it
String a="Hello!";

/**
*If you want to get character in a String,
*you can use charAt method from String class.
*Just put index of the character in it's argument.
*For your information index in String is start with
*0....so
*index 0 is for H
*index 1 is for e
*index 2 is for l
*index 3 is for l
*index 4 is for o
*index 5 is for !
**/

//Get first character in the String
char characterFirst=a.charAt(0);

//Print the first character that we get
System.out.println(characterFirst);
}
}


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

Get char array from String

Complete source code below will show you, how to get char array from a String. This char array we will store all characters in the String include white space.

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


public class GetCharArrayFromString
{
public static void main(String[]args)
{
//Create a String that we want to get character from it
//You can try other String that you want
String a="Get char array from String.........";

//Create an array from type char that will store all characters from String
//Method toCharArray() will get all characters in the String
char[]storeAllStringCharacter=a.toCharArray();

//Print number of characters in char array
System.out.println("Number of characters in char array is : "+storeAllStringCharacter.length+"\n\n");

//Print all character in char array include their index in String
System.out.println("*******************************");
System.out.println("THE CHARACTER IS : ");
System.out.println("*******************************");
System.out.println();

for(int i=0; i<storeAllStringCharacter.length; i++)
{
System.out.println("Character at index "+i+" in the String is : "+storeAllStringCharacter[i]);
}
}
}


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

RELAXING NATURE VIDEO