Convert primitive type to string in java

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


public class ConvertPrimitiveTypeToString
{
public static void main(String[]args)
{
//boolean
String a=String.valueOf(true);
System.out.println("boolean : "+a);

//byte
a=String.valueOf((byte)9);
System.out.println("byte : "+a);

//char
a=String.valueOf('a');
System.out.println("char : "+a);

//short
a=String.valueOf((short)9);
System.out.println("short : "+a);

//int
a=String.valueOf(9);
System.out.println("int : "+a);

//long
a=String.valueOf(9L);
System.out.println("long : "+a);

//float
a=String.valueOf(9.0F);
System.out.println("float : "+a);

//double
a=String.valueOf(9.0D);
System.out.println("double : "+a);
}
}


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

Convert uppercase to lowercase in java

Source code below will convert uppercase(HELLO WORLD) to lowercase(hello world)

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


public class ConvertUppercaseToLowercase
{
public static void main(String[]args)
{
String a="HELLO WORLD";

//CONVERT HELLO WORLD TO hello world
String b=a.toLowerCase();
a=b;
System.out.println(a);
}
}


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

Convert lowercase to uppercase in java

Source code below will convert lowercase (hello world) to uppercase (HELLO WORLD)

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


public class ConvertLowerCaseToUpperCase
{
public static void main(String[]args)
{
String a="hello world";

//CONVERT hello world TO HELLO WORLD
String b=a.toUpperCase();
System.out.println(b);
}
}


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

Replace word in a sentence using java

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


public class ReplaceAWordInASentence
{
public static void main(String[]args)
{
String a="Hello World";

//REPLACE Hello WITH Hi
String b=a.replaceAll("Hello","Hi");
a=b;
System.out.println(a);

//REPLACE World WITH Dude
b=a.replaceAll("World","Dude");
a=b;
System.out.println(a);
}
}


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

Replace character in a sentence in java

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


public class ReplaceCharacterInASentence
{
public static void main(String[]args)
{
String a="Hellooo Woooorld";

//REPLACE ALL CHARACTER o WITH a
String b=a.replace('o','a');
System.out.println(b);



//REPLACE A CHARACTER
//REPLACE LAST o IN Hellooo WITH a

//IF YOU WANT TO REPLACE A CHARACTER, YOU MUST TAKE WORD
//THAT CONTAIN THE CHARACTER AND MAKE SURE
//THE WORD IS ONLY UNIQUE THAT CAN REPRESENT WORD
//CONTAIN THE CHARACTER
//This is why we take looo instead of ooo because
//ooo also exist in Woooorld
String c=a.replace("looo","looa");
System.out.println(c);
}
}


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

Search character or word in a sentence using java

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


public class SearchCharacterOrWordInASentence
{
public static void main(String[]args)
{
//-1 mean the word or character that you search not exist

String a="Hello World !!!";

//SEARCH CHARACTER
int b=a.indexOf('H');
if(b!=-1)
{
System.out.println("H exist");
}

//SEARCH Hello IN Hello World !!!
int c=a.indexOf("Hello");
if(c!=-1)
{
System.out.println("Hello exist");
}
}
}


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

Get word from a sentence in java

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


public class GetWordFromASentence
{
public static void main(String[]args)
{
//This source code will show you how to get word Hello from sentence Hello World

//You can use method substring(index_for_first_letter_for_word,index_for_last_letter_plus_one)

//Index start with 0

//Blank space also count.In this case, space between Hello and world take 5 for it's index

String a="Hello world!!";
String b=a.substring(0,5);

System.out.println(b);
}
}


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

RELAXING NATURE VIDEO