Question: isError method checks if the line of string it gets has the word error at the start of it. it gets a string and returns

isError method checks if the line of string it gets has the word error at the start of it.

it gets a string and returns a boolean.

true if it found the word 'error' an the start of the line string

example use:

isError("foo bar") returns : false

isError("error foo bar") returns : true

isError("error one two") returns : true

isError("three four error") returns : false

hint: check the string methods in the java doc. one of them is helpful for this.

-------------------------------------

import java.util.*;

class Main { // your main method here public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter line:"); String line = scan.next(); System.out.println(isError(line)); } public static boolean isError(String line) { // Your code here }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!