W3schools - String/Math
이 페이지는 다음에 대한 공부 기록입니다
Lecture에서 배웠던 내용을 복습하며 작성했습니다
찾으시는 정보가 있으시다면
주제별reference를 이용하시거나
우측 상단에 있는 검색기능을 이용해주세요
Java Strings
Storing text
String variable contains a collection of characters
- surrounded by double quotes
actually, object
-
which contain method
- that can perform certain operations on strings
Method()
length() length of a string
toUpperCase(), toLowerCase()
indexOf()
- index of the first occurrence of a specified text in a string(including whitespace)
concat() : concatenation(“+”)
- ex) name.concat(lastName);
Special Characters
Strings must be written within quotes
- Java misunderstand special characters
Use backslash“\” escape character
5 other escape sequences
-
\n new line
-
\r carriage return
- move cursor to the beginning of the string and overwrite
-
\t tab
-
\b backspace
-
\f form feed
Hello it was \f great meeting
output “Hello it was
great metting”
Adding numbers and strings
If you add a number and a string, the result will be a string concatenation
Java Math
Math.max(x,y) : find the highest value of x and y
min(x,y) : lowest
abs(x) : absolute
sqrt(x) : square root
random() : returns random number between 0.0(inclusive) ~ 1.0(exclusive)