Last active
August 23, 2017 07:14
-
-
Save aya-eiya/38058c819e2ea3a2f9f50c0eb4d98684 to your computer and use it in GitHub Desktop.
初心者向けJava8ラムダ演習1 ref: http://qiita.com/aya_eiya/items/798fb1d3f87491e9f6fb
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
import java.util.List; | |
import java.util.ArrayList; | |
public class Practice1 { | |
static public void main(String[] args) { | |
List<String> helloWorld = new ArrayList<String>(3); | |
helloWorld.add("Hello"); | |
helloWorld.add(" "); | |
helloWorld.add("World"); | |
helloWorld.add("!"); | |
for (int i = 0; i < helloWorld.size(); i++) { | |
System.out.print(helloWorld.get(i)); | |
} | |
} | |
} |
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 Practice2 { | |
static public void main(String[] args) { | |
String sourceText = "this is an test script to read."; | |
int i = 0; | |
char c = sourceText.charAt(i); | |
while (c != '.') { | |
if (c > 'm') { | |
System.out.print(Character.toUpperCase(c)); | |
} else { | |
System.out.print(c); | |
} | |
c = sourceText.charAt(++i); | |
} | |
System.out.print(".\n"); | |
} | |
} |
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 Practice2A { | |
static private final int MAX = 1024; | |
static public void main(String[] args) { | |
String sourceText = "this is an test script to read."; | |
int i = 0; | |
char c = sourceText.charAt(i); | |
int sum = c; | |
while (sum < MAX) { | |
if (c > 'm') { | |
System.out.print(Character.toUpperCase(c)); | |
} else { | |
System.out.print(c); | |
} | |
c = sourceText.charAt(++i); | |
sum += c; | |
} | |
System.out.print("\n"); | |
if (sum >= MAX) { | |
System.out.println("script stopped for MAX size limitation."); | |
} | |
} | |
} |
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 Practice2A { | |
static private final int MAX = 1024; | |
static public void main(String[] args){ | |
String sourceText = "this is an test script to read."; | |
int i = 0; | |
char c = sourceText.charAt(i); | |
int sum = c; | |
while(sum < MAX){ | |
if(c > 'm'){ | |
System.out.print(Character.toUpperCase(c)); | |
}else{ | |
System.out.print(c); | |
} | |
c = sourceText.charAt(++i); | |
sum += c; | |
} | |
System.out.print("\n"); | |
if(sum >= MAX){ | |
System.out.println("script stopped for MAX size limitation."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment