摘要: import java.text.DecimalFormat; import java.util.Random; public class DecimalFormatDemo { /** * 简单格式化 * @param pattern * @param value */ public static void SimpleFormat(String pattern,double value) { DecimalFormat myFormat = new DecimalFormat(pattern); String output = myFormat.format(value); System.out.println(value + " "+ pattern + " "+ output); } /** * 使用applyPattern()方法对数字进行格式化 * @param pattern * @param value */ static public void UseApplyP 阅读全文
posted @ 2010-08-28 21:21 叮当小马 阅读(385) 评论(0) 推荐(0)
摘要: public class JavaType { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //summation String str[] = {"89","12","10","18"}; int sum = 0; for(int i=0;istr.length;i++) { int myint = Integer.parseInt(str[i]); sum += myint; } System.out.println("数组中的各种元素之和为:"+ sum); //charac String str1 = Integer.toString(456); String str2 = Integer.toBinaryString(456); String str3 = Integer.toHexString(456); 阅读全文
posted @ 2010-08-28 21:19 叮当小马 阅读(185) 评论(0) 推荐(0)