<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>侯波林的blog &#187; java 注意事项  面试题 知识点</title>
	<atom:link href="http://houbolin.cn/blog/tag/java-%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9-%e9%9d%a2%e8%af%95%e9%a2%98-%e7%9f%a5%e8%af%86%e7%82%b9/feed/" rel="self" type="application/rss+xml" />
	<link>http://houbolin.cn/blog</link>
	<description>PHP Perl APACHE MYSQL LINUX</description>
	<lastBuildDate>Mon, 13 Feb 2012 15:16:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Java常见面试题(一)</title>
		<link>http://houbolin.cn/blog/2010/07/27/java%e5%b8%b8%e8%a7%81%e9%9d%a2%e8%af%95%e9%a2%98%e4%b8%80/</link>
		<comments>http://houbolin.cn/blog/2010/07/27/java%e5%b8%b8%e8%a7%81%e9%9d%a2%e8%af%95%e9%a2%98%e4%b8%80/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 13:03:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[java学习]]></category>
		<category><![CDATA[java 注意事项  面试题 知识点]]></category>

		<guid isPermaLink="false">http://houbolin.cn/blog/?p=146</guid>
		<description><![CDATA[1 实现一个 字符串的 reverse函数和 replace函数.
reverse:

        public static void stringReverser() {
		String strOld = "aaabbb";
		String strNew = new StringBuffer(a).reverse().toString();
		System.out.println(strNew);
	}

replace:

	public static String replace(String text, String repl, String with) {
		if ((text == null) &#124;&#124; (repl == null) &#124;&#124; (with == null)
				&#124;&#124; (repl.length() == 0) &#124;&#124; (max == 0)) {
			return text;
		}

		StringBuffer buf = [...]]]></description>
			<content:encoded><![CDATA[<p>1 实现一个 字符串的 reverse函数和 replace函数.</p>
<p>reverse:</p>
<p><pre name="code" class="java">
        public static void stringReverser() {
		String strOld = "aaabbb";
		String strNew = new StringBuffer(a).reverse().toString();
		System.out.println(strNew);
	}
</pre><br />
replace:<br />
<pre name="code" class="java">
	public static String replace(String text, String repl, String with) {
		if ((text == null) || (repl == null) || (with == null)
				|| (repl.length() == 0) || (max == 0)) {
			return text;
		}

		StringBuffer buf = new StringBuffer(text.length());
		int start = 0;
		int end = 0;

		while ((end = text.indexOf(repl, start)) != -1) {
			buf.append(text.substring(start, end)).append(with);
			start = end + repl.length();
		}

		buf.append(text.substring(start));
		return buf.toString();
	}
</pre><br />
2 ArrayList 和 Vector的区别,HashMap和HashTable的区别.<br />
  就 ArrayList 和 Vector从两方面说:<br />
  一： ArrayList不是线程安全的,Vector是线程安全的,也就是说 Vector是线程同步的.具体的可以参见Vector的实现代码:</p>
<p>  二: size增长.当需要增长时,Vectory为原来默认的一倍<br />
<pre name="code" class="java">
 private void ensureCapacityHelper(int minCapacity) {
	int oldCapacity = elementData.length;
	if (minCapacity > oldCapacity) {
	    Object[] oldData = elementData;
	    int newCapacity = (capacityIncrement > 0) ?
		(oldCapacity + capacityIncrement) : (oldCapacity * 2);
    	    if (newCapacity < minCapacity) {
		newCapacity = minCapacity;
	    }
            elementData = Arrays.copyOf(elementData, newCapacity);
	}
    }
</pre><br />
   ArrayList是原来的一半.<br />
<pre name="code" class="java">
   public void ensureCapacity(int minCapacity) {
	modCount++;
	int oldCapacity = elementData.length;
	if (minCapacity > oldCapacity) {
	    Object oldData[] = elementData;
	    int newCapacity = (oldCapacity * 3)/2 + 1;
    	    if (newCapacity < minCapacity)
		newCapacity = minCapacity;
            // minCapacity is usually close to size, so this is a win:
            elementData = Arrays.copyOf(elementData, newCapacity);
	}
    }
</pre><br />
   就 HashMap 和 HashTable 而言.<br />
   一: HashMap是线程不安全的,HashTable是线程安全的</p>
<p>   二: HashMao 是可以用 null作为key和value的</p>
<p>3  char型能不能储存一个中文汉子?为什么?<br />
   答: 是能够储存一个中文汉字的,java使用的是unicode编码.一个char占16个字节,所以存储一个中文没问题哦.</p>
<p>4  多线程有几种实现方案？同步呢?<br />
   答: 有两种实现方案:<br />
	分别是继承 Runnable接口和Thread类.<br />
      同步也有两种实现方案 分别是 synchronized和notify</p>
]]></content:encoded>
			<wfw:commentRss>http://houbolin.cn/blog/2010/07/27/java%e5%b8%b8%e8%a7%81%e9%9d%a2%e8%af%95%e9%a2%98%e4%b8%80/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

