How to use simple string format with String.format() in Java

1 Answer

0 votes
import java.io.IOException;
 
public class JavaApplication {
 
    public static void main(String[] args) throws IOException {
        try {
 
            String s1 = "java";
            String s2 = "c++";
 
            String value = String.format("%s %s", s1, s2);
            System.out.println(value);
 
        } catch (Exception e) {
            System.out.print(e.toString());
        }
    }
}
 

 
/*
run:
      
java c++
   
*/

 



answered Nov 20, 2016 by avibootz
edited Jun 26, 2024 by avibootz

Related questions

1 answer 222 views
222 views asked Jul 4, 2017 by avibootz
1 answer 419 views
1 answer 223 views
1 answer 122 views
122 views asked Feb 23, 2024 by avibootz
2 answers 168 views
1 answer 139 views
...