- package com.Poker;
- import java.util.ArrayList;
- public class Poker {
- private static ArrayList<String> c;
-
- private static String [] huase ={"♥","♠","♣","♦"};
-
- private static String [] num = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
-
- public static void PokerForm(){
-
- for(int i=0;i<=num.length-1;i++){
-
- for(int j=0;j<=huase.length-1;j++){
-
- StringBuilder sb = new StringBuilder();
-
- String ss = sb.append(huase[j]).append(num[i]).toString();
-
- c.add(ss);
-
- }
- }
- }
- public static ArrayList<String> getC() {
-
- return c;
-
- }
- public static void main(String[] args) {
-
- PokerForm();
-
- }
- }
复制代码
为什么这段代码,在运行的时候会报空指针错误啊?我自己调试了下,发现是String c的add方法调用的时候发生的,可是我加的元素中没有null值啊,这是为什么呢?求大神指点一二~~~~
|
|