Hi,
I need to know if we can use the if satament with methods and how? and what is the illegal start of expression?

Recommended Answers

All 2 Replies

You can use the if statements inside your methods.

In what particular line of code do you encounter the illegal start of expression. If you have a code pls post it here (",)

if (any expression that results to a boolean) {
  // any code
} else if (...) {
  // any code
} else {
  // any code
}

That small example means that you can call anything you want inside the if statements. And you can put that if-statement wherever you want. After all the main method is also a method so you can put your ifs inside other methods that you can call.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.