Home / Programs / toString() Method in java conversion from all to String
🚀 Programming Example

toString() Method in java conversion from all to String

👁 1,312 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.

💻 Program Code

 public class WrapperoStringMethodAll {
    public static void main(String[] args){

       Integer x = 15;

       System.out.println(x.toString());
       System.out.println(Integer.toString(12));

       Double d = new Double("3.14");
       System.out.println("d = "+ d.toString() ); // result is d = 3.14
       System.out.println(Double.toString(12.32));

        Float e = new Float("6.14");
        System.out.println("e = "+ e.toString() );  // result is d = 6.14
        // System.out.println(Float.toString("15.32"));
        // no suitable method found for toString(String) 
        
        Byte f = new Byte("6");
        System.out.println("f = "+ f.toString() );   // result is d = 6
        //System.out.println(Byte.toString("8"));
        // no suitable method found for toString(String)


        Long g = new Long("76474");
        System.out.println("g = "+ g.toString() );
        //System.out.println(Long.toString("8321"));
        // no suitable method found for toString(String)

        Boolean h = new Boolean(true);
		Boolean i = new Boolean("false");
	    System.out.println("h = "+ h.toString() );
        System.out.println("i = "+ i.toString() );
        System.out.println(Boolean.toString(false));

        Character j = new Character('t');
        Character k = new Character('f');
        System.out.println("j = "+ j.toString() );
        System.out.println("k = "+ k.toString() );
        System.out.println(Character.toString('b'));
    }
}

                        

🖥 Program Output

15
12
d = 3.14
12.32
e = 6.14
f = 6
g = 76474
h = true
i = false
false
j = t
k = f
b
Press any key to continue . . .
                            
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.