随笔分类 -  java基础

摘要:1 public class Chinese { 2 public static String toUnicode(String strvalue) { 3 try { 4 if (strvalue == null) { 5 return null; 6 } 7 else { 8 strvalue = new String(strvalue.getBytes("GBK"), "ISO8859_1"); 9 return strvalue;10 }11 }12 catch... 阅读全文
posted @ 2013-06-16 00:01 ZOWIE 阅读(295) 评论(0) 推荐(0)
摘要:今天在网上看到一篇文章,看到评论,挺有意思的,所以就在此再来回顾一下题目如下所示,求出打印i的值:1 public static void main(String[] args) { 2 int i = 0; 3 for (i++; i++ < 10; i++);4 System.out.println(++i); 5 6 } 此问题主要就是考的对++i与i++的区别,对于这两者的区别,我们可以这样理解。就好比是电费付费的问题,有两种付费情况:一种是先付费,意思就是先交钱才给电用;一种是后付费,意思就是先用着电,... 阅读全文
posted @ 2013-04-18 17:44 ZOWIE 阅读(559) 评论(12) 推荐(0)
摘要:多线程同步实现对x加减一的方法 1 public class SynThreadTest { 2 private int x; 3 // 设计两个线程,一个对x加1,一个对x减1 4 5 public static void main(String[] args) { 6 SynThreadTest stt = new SynThreadTest(); 7 inc inc =stt.new inc(); 8 Thread threadA = new Thread(inc); 9 threadA.start... 阅读全文
posted @ 2013-03-28 11:10 ZOWIE 阅读(365) 评论(0) 推荐(0)