dimanche 13 mai 2018

Illegal expression during if statement (Java)

I am trying to code a text-based calculator with the ability to calculate long calculations in Java netbeans. During the coding of a conceptual piece of code I got an error message saying that my if statement had an illegal start of expression. I am new to programming, but a more experienced friend of mine who helped me couldn't figure out the problem either. The code looks like this:

package eksamensprojekt;

public class Eksamensprojekt {

public static void main(String[] args) {

    java.util.Scanner tastatur = new java.util.Scanner(System.in);
    String regnestykke;
    System.out.println("Skriv dit regnestykke");
    regnestykke = tastatur.nextLine();

    if(regnestykke.contains(*))
        {
    System.out.println("123");

}

} }

Right now we are just trying to make it check if there is a * sign in the text you write into 'regnestykke'. Anyway, it would be great if one of you could tell us what is wrong. Sorry if the answer is obvious.

Aucun commentaire:

Enregistrer un commentaire