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 3966214
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:34:14+00:00 2026-05-20T03:34:14+00:00

I have asked a couple of questions about this for loop: String[] book =

  • 0

I have asked a couple of questions about this for loop:

  String[] book = new String [ISBN_NUM];
  bookNum.replaceAll("-","");
  if (bookNum.length()!=ISBN_NUM)
    throw new ISBNException ("ISBN "+ bookNum + " must be 10 characters");
  for (int i=0;i<bookNum.length();i++)
  {
      if (Character.isDigit(bookNum.charAt(i)))
      book[j]=bookNum.charAt(i);  //this is the problem right here
      j++;
      if (book[9].isNotDigit()|| 
          book[9]!="x"        ||
          book[9]!="X")
      throw new ISBNException ("ISBN " + bookNum + " must contain all digits" + 
                               "or 'X' in the last position");
  }

which will not compile. An answer I had from the other question I asked told me that the line where the error occurs is wrong in that bookNum.charAt(i) is an (immutable) string, and I can’t get the values into a book array that way. What I need to do on my assignment is check an ISBN number (bookNum) to see that it is all numbers, except the last digit can be an ‘x’ (valid ISBN). Is this the best way to do it? If so, what the hell am I doing wrong? If not, what method would be a better one to use?

  • 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-20T03:34:15+00:00Added an answer on May 20, 2026 at 3:34 am

    book is of type String[] (array of strings), bookNum.charAt(i) returns a char. You can’t assign a String from a char.

    Do book[j] = String.valueOf(bookNum.charAt(i)) instead.

    Also you might want to change the first error:

    throw new ISBNException ("ISBN "+ bookNum + " must be " + ISBN_NUM + " characters");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've asked a couple of questions about performing joins and have had great
In the last couple of days I asked a couple of questions about delegates
I've noticed a couple other questions about handling this, but all seem to suffer
This is a continuation question from a previous question I have asked I now
I've look all over the web and in the questions asked here about MySQL
I realize this question is very likely to have been asked before, but I've
Been trying to figure this out for a couple of hours now and have
I have found this example on StackOverflow: var people = new List<Person> { new
I had asked a couple of question about multilanguage in asp.net and I am
I asked a question a couple weeks ago about using setTimeout for a factorial

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.