Skip to content

Instantly share code, notes, and snippets.

@aya-eiya
Last active August 23, 2017 07:14
Show Gist options
  • Save aya-eiya/38058c819e2ea3a2f9f50c0eb4d98684 to your computer and use it in GitHub Desktop.
Save aya-eiya/38058c819e2ea3a2f9f50c0eb4d98684 to your computer and use it in GitHub Desktop.
初心者向けJava8ラムダ演習1 ref: http://qiita.com/aya_eiya/items/798fb1d3f87491e9f6fb
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));
}
}
}
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");
}
}
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.");
}
}
}
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