-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_087_HasJava.java
More file actions
51 lines (36 loc) · 897 Bytes
/
_087_HasJava.java
File metadata and controls
51 lines (36 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package Repl_it_Tasks;
import java.util.Scanner;
public class _087_HasJava {
/*
Given a string word, print true if "java"
appears starting at index 0 or 1 in the
string, such as with "javaxxx" or "xjavaxx"
but not "xxjavaxx". The string may be any
length, including 0word = .
Example:
input: javapython
output: true
Example:
input: cjavac++
output: true
Example:
input: c#javaruby
output: false
*/
public static void main(String[] args) {
boolean exists = false;
Scanner scan = new Scanner(System.in);
String word = scan.next();
if(word.length() >=4) {
if((word.substring(0,4).contains("java")) || (word.substring(1,5).contains("java"))){
System.out.println(!exists);
}
else {
System.out.println(exists);
}
}
else {
System.out.println(exists);
}
}
}