3:53 pm - Thursday March 25, 8838

String Example Program for format(String format,Object… args)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
@AUTHOR: candid java
@DESCRIPTION: coding  for return a formatted string using a specified format string and arguments
*/

public class Format {
  public static void main(String[] argv) {
    System.out.println(String.format("%4d", 11));// return a decimal integer with 4 space
    System.out.println(String.format("%6d", 222)); // return a decimal integer with 6 space
    System.out.println(String.format("%4d", 333333333)); // return a decimal integer with 4 space
  }
}

OUTPUT:
11
222
333333333

BACK

Filed in: Z-A All Java Codes

Comments are closed.