Monday 7 May 2012

Java String format(String format)Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
String class format(String format) method example

String class format(String format) method example. This example shows you how to use format(String format) method.This method  Returns a formatted string using the specified format string and arguments.

  


Here is the code:-
/* 
 * @(#) Formatstring1.java
 *Program  Returns a formatted string using the specified format string and arguments.
 */


import java.util.*;
public class Formatstring1
  {    
    public static void main(String[] args)
    {
      long n = 461012;
    //Returns a formatted string using the specified format string and arguments.
      System.out.format("%d%n", n); 
      System.out.format("%08d%n", n);
     
    }
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...