`
cooliufang
  • 浏览: 129877 次
社区版块
存档分类
最新评论

A question about char and String?

    博客分类:
  • Java
阅读更多
I find out a quesiton, only record it, when i have time, i will study it.

package com.patsnap;

import java.util.Arrays;
import java.util.List;

public class TestListChar {
	public static void main(String[] args) {
		char[] arr = {',','-','-','?'};
		List<char[]> list = Arrays.asList(arr);
		char c = '?';
		if (list.contains(c)) {
			System.out.println("char");
		}
		
		String[] arrStrings = {"-",",","?"};
		List<String> list2 =  Arrays.asList(arrStrings);
		String s = "?";
		if (list2.contains(s)) {
			System.out.println("string");
		}
	}
}


The output is : string.
The question is: why list.contains(c) is false?
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics