CODING:
import java.text.DecimalFormat;
class tostring
{
public static void main(String args[])
{
int a = 666;
int b = -666;
String s1 = Integer.toString(a);
String s2 = String.valueOf(b);//also define String.valueOf(-666)
System.out.println("String s1 = " + s1);
System.out.println("String s2 = " + s2);
int c = 616;
Integer o = new Integer(c);
String s3 = o.toString();
System.out.println("String s3 = " + s3);
//String s3 = new Integer(c).toString();
//String s3 = new Integer(616).toString();
DecimalFormat o2 = new DecimalFormat("#,###");
String s4 = o2.format(66666);
System.out.println("String s4 = " + s4);
String s5 = new StringBuffer().append(6666).toString();
System.out.println("String s5 = " + s5);
String s6 = new StringBuilder().append(3333).toString();
System.out.println("String s6 = " + s6);
String binaryString = Integer.toBinaryString(333);
System.out.println(binaryString);
//Integer.toOctalString(),Integer.toHexString(j);
String customString = Integer.toString(666, 7);//the base 7 number system
System.out.println(customString);
}
}
class tostring
{
public static void main(String args[])
{
int a = 666;
int b = -666;
String s1 = Integer.toString(a);
String s2 = String.valueOf(b);//also define String.valueOf(-666)
System.out.println("String s1 = " + s1);
System.out.println("String s2 = " + s2);
int c = 616;
Integer o = new Integer(c);
String s3 = o.toString();
System.out.println("String s3 = " + s3);
//String s3 = new Integer(c).toString();
//String s3 = new Integer(616).toString();
DecimalFormat o2 = new DecimalFormat("#,###");
String s4 = o2.format(66666);
System.out.println("String s4 = " + s4);
String s5 = new StringBuffer().append(6666).toString();
System.out.println("String s5 = " + s5);
String s6 = new StringBuilder().append(3333).toString();
System.out.println("String s6 = " + s6);
String binaryString = Integer.toBinaryString(333);
System.out.println(binaryString);
//Integer.toOctalString(),Integer.toHexString(j);
String customString = Integer.toString(666, 7);//the base 7 number system
System.out.println(customString);
}
}
Comments
Post a Comment