import java.util.*;
class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//basic setup
int a = sc.nextInt();
int[] arr1 = new int[50];
// just showing that int and int[] is normal lmao
String str = sc.next();
char[] charr = new char[50];
// THERE IS NO SUCH THING AS STRING[]
// ONLY CHAR[]
charr = str.toCharArray();
// adding a String to a char[]
String b = new String(charr);
System.out.println(b);
// turning a char[] into string
/*
for(int i=0;i<arr1.length;i++) {
System.out.println(arr1[i]);
// int[] CAN USE arrName[i]
}
for(int i=0;i<charr.length;i++) {
System.out.println(charr[i]);
// AND char[] CAN USE arrName[i]
}
for(int i = 0;i<str.length();i++) {
System.out.println(str.charAt(i));
// BUT strName[i] DOES NOT WORK BECAUSE STRINGS CAN'T DO [i]
// STRINGS USE .charAt INSTEAD OF [i] like a list
}
*/
// if(b.equals("hello")) // YES bc it compares the value
// if(b == "hello") // NO bc a String is a location to memory
String[] arr = b.split("-");
// splitting String and saving in String[]
System.out.println(arr[0]);
char x = 'a';
// ASCII CONVERSION
// (int) AND (char)
System.out.println((int)x);
System.out.println((char)97);
}
}
top of page
기능을 테스트하려면 라이브 사이트로 이동하세요.
java String and arrays and ASCII
java String and arrays and ASCII
댓글 0개
좋아요
댓글(0)
bottom of page