小编juj*_*uju的帖子

在 Java 中,字符串是字符数组吗?

我想知道,如果 aString是一个集合。我已经阅读了,但仍然很困惑。

java string

7
推荐指数
1
解决办法
1万
查看次数

我可以将对象从字符串的对象数组转换为字符串.获取classCastException

我可能很傻,但它让我疯了.我已经四处寻找,但我对编程比较陌生,而且我已经掌控了.如果可以的话请帮忙!bar参数是一个arraylist.toArray(),它只是字符串.

public bar(Object[] contents) {

    for (Object o : contents) {
        String s = (String) o;
        if (s == null) {
            System.out.println("newline"); //checking
        } else  {
            try {
                arrayContents.add(new line(s));

            } catch (Exception ex) {
                System.out.println("error printing note: " + s + " " + ex + " in bar " + i);
            }
        }
        i++;

    }
//        System.out.println(arrayContents);
}
Run Code Online (Sandbox Code Playgroud)

java arrays string object classcastexception

3
推荐指数
1
解决办法
87
查看次数

这种单一的静态方法有什么作用?

我不确定这是做什么的,我以前没见过,也找不到任何有关它的信息.

private static String[] names = { "A.ttf" };

private static Map<String, Font> cache = new ConcurrentHashMap<String, Font>(names.length);

static {
  for (String name : names) {
    cache.put(name, getFont(name));
  }
}
Run Code Online (Sandbox Code Playgroud)

java fonts static

0
推荐指数
1
解决办法
114
查看次数

标签 统计

java ×3

string ×2

arrays ×1

classcastexception ×1

fonts ×1

object ×1

static ×1