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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | String class valueOf method example. String class valueOf method example:- This example demonstrates the working of valueOf method. this method returns String representations of all data types values Syntax:-valueOf(boolean b) Here is the code:- /** * @(#) ValueOfString.java * ValueOfString class demonstrates the working of valueOf() method of String class of lang package */ public class ValueOfString { public static void main(String args[]) { // method converts any data type value in to String type boolean result = true; int in = 234; char ch = 'u'; double dou = 34.86; float flt = 54.889f; System.out.println("String represented boolean value: " + String.valueOf(result) + "\nString represented integer value: " + String.valueOf(in) + "\nString represented char value: " + "'" + String.valueOf(ch) + "'" + "\nString represented double value: " + String.valueOf(dou) + "\nString represented float value: " + String.valueOf(flt)); } } Output of the program:- --------------------------------------- String represented boolean value: true String represented integer value: 234 String represented char value: 'u' String represented double value: 34.86 String represented float value: 54.889 |
It's all about Java development. A place mainly for java programmers.
Monday, 7 May 2012
Java String valueOf Example
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment