Created
January 23, 2016 19:37
-
-
Save kishida/4011703d73b2608d2f43 to your computer and use it in GitHub Desktop.
Single thread program.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SingleThread { | |
public static void main(String[] args) { | |
StringBuilder sb = new StringBuilder(); | |
String str = "abc(cdef)gh(ijk)lmn"; | |
int i = 0; | |
boolean inParenthesis = false; | |
for(;;){ | |
if(i >= str.length()){ | |
break; | |
} | |
char ch = str.charAt(i); | |
switch(ch){ | |
case '(': | |
inParenthesis = true; | |
break; | |
case ')': | |
inParenthesis = false; | |
break; | |
default: | |
if(inParenthesis){ | |
sb.append(ch); | |
} | |
} | |
++i; | |
} | |
System.out.println(sb); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output only in a parenthesis.