Does the code you posted compile? If not, copy full text of error messages and paste here.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
it says that name1 and name2 cannot be resolved,
Where are those two variables defined? Are their definitions "in scope" where you are trying to use them. In scope roughly means is the definition and usage within the SAME enclosing pair of {}s.
Where is the method charAt() defined? The IDE can't find its definition.
there is a syntax error on the int length
No idea what your IDE means here. You need to post the errors with the lines of code that are causing them.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Cannot make a static reference to the non-static method length() from the type Name Name.java /HW3/src line 44
That refers to
return Name.length();
What value do you want to return in the length() method? You need to decide what value to return here.
The syntax of the statement says that length() is a static method in the Name class. If length() were static, that call would be recursive and would result in an infinite recursion (it would call itself until the JVM ran out of memory)
hy the boolean statement in my code is commented out.
Sorry I missed the reason or problem you are having here. Can you explain?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What value do you want to return from your length method? Without knowing that, I can't tell you what to code.
You need to read the API doc for the String method to see how to use the length() method.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Does it return the desired value?
What does the variable: name contain? Is it the first+middle+last? with or without separating spaces?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What variable is at line 47 in the program? It needs to have a value that is not null.
Your code should test if the variable is null and return a zero.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Question Answered as of 2 Years Ago by
NormR1