Created
April 2, 2015 07:46
-
-
Save Togami-Arahi/b1bf26c6586f72cb7ccf to your computer and use it in GitHub Desktop.
This file contains 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
// http://www.javadrive.jp/start/string/index6.htmlからコピペ | |
class Connect{ // JSample6_1 | |
public static void main(String args[]){ | |
String str1 = "パトカー"; // 腕時計からパトカーに改変 | |
String str2 = "タクシー"; // 追加 | |
int i,j; | |
/*for (i = 0,j = 0; i < str1.length(); i++,j++){ | |
char c1 = str1.charAt(i); | |
char c2 = str2.charAt(j); | |
}*/ | |
//配列と繰り返しで短くなりそう(上手く扱えない) | |
char c11 = str1.charAt(0); | |
char c12 = str1.charAt(1); | |
char c13 = str1.charAt(2); | |
char c14 = str1.charAt(3); | |
char c21 = str2.charAt(0); | |
char c22 = str2.charAt(1); | |
char c23 = str2.charAt(2); | |
char c24 = str2.charAt(3); | |
// http://www.techscore.com/blog/2012/11/29/%E6%96%87%E5%AD%97%E5%88%97%E7%B5%90%E5%90%88-java%E7%B7%A8/からコピペしてワチャワチャ | |
StringBuilder buf = new StringBuilder(); | |
buf.append(c11); | |
buf.append(c21); | |
buf.append(c12); | |
buf.append(c22); | |
buf.append(c13); | |
buf.append(c23); | |
buf.append(c14); | |
buf.append(c24); | |
String c = buf.toString(); | |
System.out.println(c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment