KnowledgeBoat Logo
|

Computer Applications

Cyber police wanted to investigate a case; they wanted to check a list of phone numbers that had 945 anywhere in the phone number. Example: 7394567938, 7685483945.., a method was created to convert the phone number in long data type to a string and check for the existence of the number 945. Fill in the blanks (a) and (b) in the given method with appropriate Java statements:

void check(long pno) 
{ String s = _______(a)_________; 
if(______(b)_______) 
    System.out.println(pno); 
}                                    

Java String Handling

15 Likes

Answer

void check(long pno) 
{ String s = String.valueOf(pno); 
if(s.indexOf("945") >= 0) 
    System.out.println(pno); 
}                                    

Answered By

9 Likes


Related Questions