Note that there are some explanatory texts on larger screens.

plurals
  1. POmethod declaration gives an error. What gives?
    primarykey
    data
    text
    <p>So I'm still plugging away at my big assignment (thanks to everyone for helping me figure out the problem with my loop). Now i have moved on to start making a checkDigit() method that is used to validate whether the check digit on the isbn # is valid (which I have only started screwing around with). Here's the problem: I tried to compile it, but the compiler tells me that there is an expected at the method call. Here is a snippet of my beginner's code:</p> <pre><code> private String validateISBN(String bookNum)throws ISBNException { boolean check=false; bookNum.replaceAll("-",""); if (bookNum.length()!=ISBN_NUM) throw new ISBNException ("ISBN "+ bookNum + " must be 10 characters"); for (int i=0;i&lt;bookNum.length()-1;i++) { if (Character.isDigit(bookNum.charAt(i))) check=true; } if (bookNum.charAt(9)=='X') check=true; if (Character.isDigit(bookNum.charAt(9))) check=true; if (check=false) throw new ISBNException ("ISBN " + bookNum + " must contain all digits" + "or 'X' in the last position"); if (checkDigit()=false) throw new ISBNException ("ISBN " + bookNum + " is invalid.\n" + "ISBN " + bookNum + " should be " + validnum); if (check=true) return bookNum; } public boolean checkDigit (bookNum) { double total=0.0; char[] check = {1,2,3,4,5,6,7,8,9,X}; int[] checkNums= {1,2,3,4,5,6,7,8,9,10}; for (int i=0;i&lt;bookNum.length;i++) check(i)=bookNum[i]; total+=check[i]*checkNums[i]; </code></pre> <p>What exactly does this mean? Normally it only means that I am missing a curly brace somewhere, but that is not the case this time. </p> <p>edit</p> <p>Sorry for the obvious and stupid question. For you guys who asked to see the actual compiler message, I put it up top (buried), it was that the compiler</p> <p>identifier expected</p> <p>but I actually put the &lt;> tags around identifier, so it took out the word identifier, and now it says, "....but the compiler tells me that there is an expected at the method call, instead of, " ....but the compiler tells me that there is an identifier expected at the method call.</p> <p>And the enter that was originally at the start was from the text field (which I am typing the question) for when I pasted the code, it said 'enter code here', and I didn't take out the enter.</p> <p>Sorry</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload