Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am taking an intro to java class, and I have to make a chicken class with a method walk(). I have everything done, but the method walk().
public void walk();
{
System.out.print( Chicken + "is walking." );
}
This is what I'm trying, and I am getting a compile time error
Chicken.java:25: error: missing method body, or declare abstract
public void walk();
Chicken.java:27: error: cannot find symbol
System.out.print( Chicken + "is walking." );
symbol: variable Chicken
location: class Chicken
Any help would be appreciated, and thanks!
That is because of a semi colon after walk(). It denotes the end of statement, all you need to do is to remove it and the code will compile. E.g.
public void walk(){
System.out.print( Chicken + "is walking." );
}
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I know that it may be a silly mistake but I am looking at this code for about 15 minutes and I cannot see nothing wrong. Besides I can continue to do my work with this error.
I have the following method
GetMapping("/pagina/imoveis-residenciais-venda")
------------------------------------------------- (red marker of error)
public List<Imovel> recuperarPaginaImoveisResidenciaisVenda(){
List<Imovel> imoveis = this.imovelRepositorio.recuperarPaginaImoveisResidenciaisVenda();
return imoveis;
}
And the following error message, as GetMapping is underlined with the red marker:
invalid method declaration, required return type
GetMapping is an annotation, and annotation must start with an # sign so your code should look like this
#GetMapping("/pagina/imoveis-residenciais-venda")
public List<Imovel> recuperarPaginaImoveisResidenciaisVenda(){
List<Imovel> imoveis = this.imovelRepositorio.recuperarPaginaImoveisResidenciaisVenda();
return imoveis;
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
i have a simple function inside a class that checks if two strings are equal ( this is for a hangman game). The code is simple, with two class variables:
private String hiddenWord;
private String dashWord;
public void compareGuessWord(String clientGuess) {
if (clientGuess.length() > 1) {
System.out.println("Kollar om dashord: " + dashWord);
System.out.println("Kollar om hidden: " + this.hiddenWord);
System.out.println("Kollar om guess:" + clientGuess);
if (clientGuess.equalsIgnoreCase(this.hiddenWord));
{
this.dashWord = clientGuess;
}
System.out.println("SECOND Kollar om guess:" + clientGuess);
System.out.println("SECOND Kollar om dashord: " + dashWord);
System.out.println("SECOND Kollar om hidden: " + hiddenWord);
}
}
Here is the console output, which u can see that it is running the inner if even though they dont match.
problem
if (clientGuess.equalsIgnoreCase(this.hiddenWord)); Your if does nothing but checking. Remove the ; after it.
In your if condition have ';' so that if is not working
if (clientGuess.equalsIgnoreCase(this.hiddenWord))**;**
{
this.dashWord = clientGuess;
}
The compiler consider it as a normal statement, so remove semicolon ";" and check
your If Statement is getting terminated as you had put semicolon at the end
if (clientGuess.equalsIgnoreCase(this.hiddenWord));
remove the semicolon and it will work fine
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
public class project5{
public static void main(String args[]){
String[] storage = {"123457897", "123456","654654654"};
int current;
current = Integer.parseInt(storage[1].subString(1,5));
System.out.println(current);
}
}
So I'm trying to, as an exercise, just get the first 5 numbers in the first thing of the array and parse it as an integer and store it as the variable current. It gives me the error:
test.java:5: error: cannot find symbol
current = Integer.parseInt(storage[1].subString(1,5));
^
symbol: method subString(int,int)
location: class String
1 error
What is it that I'm doing wrong?
There is no subString method on the String class. There only is substring (all lowercase).
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
For variable, class and method names casing matters.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am having a problem when I am trying to compile a pattern program. I am creating this program in BLUEJ and when I am trying to compile it shows the error : "not a statement"
class pattern
{
public static void main()
{
int p=0;
for(int i=1;p=1;i<=4;i++,p++)
{
for(int j=1;j<=i;j++)
{
System.out.print(Math.pow(p,2);
}
System.out.println();
}
}
}
What is the problem?
A couple of issues there, the main one being this:
for(int i=1;p=1;i<=4;i++,p++)
// ^ ^ ^
The for statement consists of three, not four, parts separated with ;. I suspect you wanted
for(int i=1,p=1;i<=4;i++,p++)
// ^--- comma here
Separately, I believe you have to specify the argument to main even if you're not using it, so:
public static void main(String[] args)
In a comment on the qustion, cadrian pointed out a further problem:
System.out.print(Math.pow(p,2);
// Missing ) here ------------^
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 days ago.
Improve this question
I tried to check if a property was equal to a string but I keep getting this error
Code:
if (prop.getProperty("quit").equal("true")) {
}
Error:
cannot find symbol
symbol: method equal(java.lang.String)
location: class java.lang.String
The method name is equals not equal.