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 225 views
225 views asked Jul 4, 2017 by avibootz
1 answer 423 views
1 answer 228 views
1 answer 126 views
126 views asked Feb 23, 2024 by avibootz
2 answers 170 views
1 answer 144 views
...