Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Jesse Black   on Jul 13 In Java Category.

  
Question Answered By: Holly Brown   on Jul 13

Question #1: If you really need to store  the string
"-1" in the array  you will have to create an array of
Strings. Then add the string  "-1" to elements 0-65
then add the letters  (actually one character strings)
to elements 66-99.
Ex.

int negOneLimit = 65;
String[] A = new String[100];
String negOne = "-1";
String someRandomChar = "X";
for(int i = 0; i < A.length; i++){
if(i <= negOneLimit)
A[i] = negOne;
else
A[i] = someRandomChar;
}

Note that there is not character representation for
"-1" so I had to use an array of strings. If you can
substitute "-1" for a single character then you would
use an array of char instead.

Question #2: You will have to post the error messages
that you get here if you want someone to help you.

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How can I store a string in an array? Or get search suggestion and latest updates.


Tagged: