File tree 2 files changed +76
-0
lines changed
2 files changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Compiled class file
2
+ * .class
3
+
4
+ # Log file
5
+ * .log
6
+
7
+ # BlueJ files
8
+ * .ctxt
9
+
10
+ # Mobile Tools for Java (J2ME)
11
+ .mtj.tmp /
12
+
13
+ # Package Files #
14
+ * .jar
15
+ * .war
16
+ * .ear
17
+ * .zip
18
+ * .tar.gz
19
+ * .rar
20
+
21
+ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22
+ hs_err_pid *
23
+
24
+ # IDEA project files
25
+ .idea
26
+ * .iml
27
+
28
+ # out
29
+ /out
30
+
31
+ # SQLite database
32
+ /dbase
33
+
34
+ # Local libraries
35
+ /lib
36
+
37
+ # Keys
38
+ config.properties
Original file line number Diff line number Diff line change
1
+ package easy ;
2
+
3
+ import java .util .regex .Matcher ;
4
+ import java .util .regex .Pattern ;
5
+
6
+ /**
7
+ * Have the function ABCheck(str) take the str parameter being passed
8
+ * and return the string true if the characters a and b are separated by exactly 3 places
9
+ * anywhere in the string at least once (i.e. "lane borrowed" would result in true
10
+ * because there is exactly three characters between a and b). Otherwise, return the string false.
11
+ */
12
+ public class AbCheck {
13
+
14
+ /**
15
+ * AB Check function.
16
+ *
17
+ * @param str input string
18
+ * @return the string true if the characters a and b are separated by exactly 3 places
19
+ */
20
+ private static String abCheck (String str ) {
21
+ Pattern pattern = Pattern .compile ("(a...b|b...a)" );
22
+ Matcher matcher = pattern .matcher (str );
23
+ return matcher .find () ? "true" : "false" ;
24
+ }
25
+
26
+ /**
27
+ * Entry point.
28
+ *
29
+ * @param args command line arguments
30
+ */
31
+ public static void main (String [] args ) {
32
+ var result1 = abCheck ("lane borrowed" );
33
+ System .out .println (result1 );
34
+ var result2 = abCheck ("australia" );
35
+ System .out .println (result2 );
36
+ }
37
+
38
+ }
You can’t perform that action at this time.
0 commit comments