YouTip LogoYouTip

String Format

# Java Example - String Formatting [![Image 3: Java Example](#) Java Example](#) The following example demonstrates how to format strings using the format() method, and also allows specifying a locale for formatting: ## StringFormat.java File import java.util.*; public class StringFormat{public static void main(String[]args){double e = Math.E; System.out.format("%f%n", e); System.out.format(Locale.CHINA , "%-10.4f%n%n", e); //Set the locale to China (CHINA)}} The output of the above code example is: 2.7182822.7183 [![Image 4: Java Example](#) Java Example](#)
← Python String LengthPyhton Remove Ith Character Fr β†’