Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
public static void main (String[]args) {
  float num = 567e1f;
   double secondnum =           789.8654E10d;
System.out.println("Your answer is" + num + "and" + secondnum);
     }
}

How to add spaces between words ?
My output is : Your answer is5670.0and7.898654E12

What I have tried:

I tried adding " " but didn't worked.
Posted
Updated 27-Jun-23 2:15am
v2

1 solution

The program
Java
public class Foo
{ 
  public static void main (String[] args)
  {
    float num = 567e1f;
    double secondnum = 789.8654E10d;
    System.out.println("Your answer is " + num + " and " + secondnum);
  }

}


The output
Your answer is 5670.0 and 7.898654E12
 
Share this answer
 
Comments
Richard MacCutchan 27-Jun-23 8:20am    
Brilliant +5.
CPallini 27-Jun-23 8:46am    
Well, this time I had to squeeze my brain. :-D
Thank you.
Andre Oosthuizen 27-Jun-23 10:49am    
Out if this world! +5 :)
CPallini 28-Jun-23 1:48am    
:-D Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900