Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 732761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:10:44+00:00 2026-05-14T07:10:44+00:00

I got this error message and I’m not quite sure whats wrong: Exception in

  • 0

I got this error message and I’m not quite sure whats wrong:

Exception in thread "main" java.lang.NullPointerException
    at Risk.runTeams(Risk.java:384)
    at Risk.blobRunner(Risk.java:220)
    at Risk.genRunner(Risk.java:207)
    at Risk.main(Risk.java:176)

Here is the relevant bits of code (i will draw attention to the line numbers within the error message via comments in the code as well as inputs i put into the program while its running where relevant)

public class Risk
{

…

public static void main (String[]arg) 
{
    String CPUcolor = CPUcolor () ; 
    genRunner (CPUcolor) ; //line 176

…

}

…

public static void genRunner (String CPUcolor) // when this method runs i select 0 and run blob since its my only option. Theres nothing wrong with this method so long as i know, this is only significant because it takes me to blob runner and because another one of our relelvent line numbers apears. 
{
    String[] strats = new String[1] ; 
    strats[0] = "0 - Blob" ;
    int s = chooseStrat (strats) ;
    if (s == 0) blobRunner (CPUcolor) ; // this is line 207 
}

…

public static void blobRunner (String CPUcolor) 
{ 
    System.out.println ("blob Runner") ; int turn = 0 ; boolean gameOver = false ; 
    Dice other = new Dice ("other") ; 
    Dice a1 = new Dice ("a1") ; Dice a2 = new Dice ("a2") ; Dice a3 = new Dice ("a3") ;
    Dice d1 = new Dice ("d1") ; Dice d2 = new Dice ("d2") ; 
    space (5) ; 
    Territory[] board = makeBoard() ; 
    IdiceRoll (other) ; 
    String[] colors = runTeams(CPUcolor) ; //this is line 220 
    Card[] deck = Card.createDeck () ;
    System.out.println (StratUtil.canTurnIn (deck)) ; 

    while (gameOver == false)
    {
        idler (deck) ; 
        board = assignTerri (board, colors) ; 
        checkBoard (board, colors) ; 
    }
} 

…

public static String[] runTeams (String CPUcolor) 
{  
    boolean z = false ; 
    String[] a = new String[6] ; 
    while (z == false) 
    { 
        a = assignTeams () ; 
        printOrder (a) ;
        boolean CPU = false ; 
        for (int i = 0; i<a.length; i++) 
        { 
            if (a[i].equals(CPUcolor)) CPU = true ; //this is line 384
        }
        if (CPU==false) 
        {
            System.out.println ("ERROR YOU NEED TO INCLUDE THE COLOR OF THE CPU IN THE TURN ORDER") ; 
            runTeams (CPUcolor) ;
        }
        System.out.println ("is this turn order correct? (Y/N)") ; 
        String s = getIns () ; 
        while (!((s.equals ("y")) || (s.equals ("Y")) || (s.equals ("n")) || (s.equals ("N")))) 
        {
            System.out.println ("try again") ; 
            s = getIns () ; 
        } 
        if (s.equals ("y") || s.equals ("Y") ) 
        z = true ; 
    } 
    return a ; 
}

…

} // This } closes the class 

The reason i don’t think i should be getting a Null:pointerException is because in this line: a[i].equals(CPUcolor) a at index i holds a string and CPUcolor is a string. Both at this point definatly have a value neither is null. Can anyone please tell me whats going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:10:45+00:00Added an answer on May 14, 2026 at 7:10 am

    you should take a look at the method assignTeams(). for some value of i, a[i] has to be null. it doesn’t matter if CPUcolor is null, the method equals handles that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.