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

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?
分享到:
评论

相关推荐

    Using LUA with Visual C++ (Introduction)

    Don't forget that this document is only a quick introduction and that it is not a complete tutorial about LUA. How to embed LAU into C++? Another way to formulate this question : "How can I use ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Maintaining a uniform style and following conventions means that we can more easily use "pattern-matching" to infer what various symbols are and what invariants are true about them. Creating common, ...

    2009 达内Unix学习笔记

    [] 匹配中括号里的内容[a-z][A-Z][0-9]。 ! 事件。 $ 取环境变量的值。 | 管道。把前一命令的输出作为后一命令的输入,把几个命令连接起来。 |经常跟tee连用,tee 把内容保存到文档并显示出来。 三、通用后...

    Turbo C++ 3.0[DISK]

    If you still have a question and need assistance, help is available from the following sources: 1. Type GO BPROGB on the CompuServe bulletin board system for instant access to the Borland forums ...

    Turbo C++ 3.00[DISK]

    If you still have a question and need assistance, help is available from the following sources: 1. Type GO BPROGB on the CompuServe bulletin board system for instant access to the Borland forums ...

Global site tag (gtag.js) - Google Analytics