บทช่วยสอนJava

Java HOME Java Intro Java เริ่มต้น Java Syntax ความคิดเห็นของ Java ตัวแปร Java Java Data Types การหล่อแบบจาวา ตัวดำเนินการ Java Java Strings Java Math Java Booleans Java If...Else Java Switch Java ในขณะที่ลูป Java สำหรับลูป Java Break/ต่อ Java Arrays

เมธอดของจาวา

เมธอดของจาวา พารามิเตอร์เมธอด Java วิธี Java โอเวอร์โหลด ขอบเขต Java Java Recursion

คลาส Java

Java OOP Java Classes/Objects คุณสมบัติคลาส Java วิธีการคลาส Java Java Constructors Java Modifiers การห่อหุ้มด้วยจาวา แพ็คเกจ Java / API มรดกจาวา Java Polymorphism Java Inner Classes Java Abstraction อินเทอร์เฟซ Java Java Enums อินพุตผู้ใช้ Java Java วันที่ Java ArrayList Java LinkedList Java HashMap Java HashSet Java Iterator คลาส Java Wrapper ข้อยกเว้น Java Java RegEx Java Threads จาวา แลมบ์ดา

การจัดการไฟล์ Java

ไฟล์ Java Java สร้าง/เขียนไฟล์ Java อ่านไฟล์ Java ลบไฟล์

Java ฮาวทู

เพิ่มสองตัวเลข

Java Reference

คีย์เวิร์ด Java เมธอด Java String Java Math Methods

ตัวอย่าง Java

ตัวอย่าง Java Java Compiler แบบฝึกหัด Java Java Quiz ใบรับรอง Java


เมธอด Java String


วิธีการสตริงทั้งหมด

คลาส String มีชุดเมธอดในตัวที่คุณสามารถใช้กับสตริงได้

Method Description Return Type
charAt() Returns the character at the specified index (position) char
codePointAt() Returns the Unicode of the character at the specified index int
codePointBefore() Returns the Unicode of the character before the specified index int
codePointCount() Returns the number of Unicode values found in a string. int
compareTo() Compares two strings lexicographically int
compareToIgnoreCase() Compares two strings lexicographically, ignoring case differences int
concat() Appends a string to the end of another string String
contains() Checks whether a string contains a sequence of characters boolean
contentEquals() Checks whether a string contains the exact same sequence of characters of the specified CharSequence or StringBuffer boolean
copyValueOf() Returns a String that represents the characters of the character array String
endsWith() Checks whether a string ends with the specified character(s) boolean
equals() Compares two strings. Returns true if the strings are equal, and false if not boolean
equalsIgnoreCase() Compares two strings, ignoring case considerations boolean
format() Returns a formatted string using the specified locale, format string, and arguments String
getBytes() Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array byte[]
getChars() Copies characters from a string to an array of chars void
hashCode() Returns the hash code of a string int
indexOf() Returns the position of the first found occurrence of specified characters in a string int
intern() Returns the canonical representation for the string object String
isEmpty() Checks whether a string is empty or not boolean
lastIndexOf() Returns the position of the last found occurrence of specified characters in a string int
length() Returns the length of a specified string int
matches() Searches a string for a match against a regular expression, and returns the matches boolean
offsetByCodePoints() Returns the index within this String that is offset from the given index by codePointOffset code points int
regionMatches() Tests if two string regions are equal boolean
replace() Searches a string for a specified value, and returns a new string where the specified values are replaced String
replaceFirst() Replaces the first occurrence of a substring that matches the given regular expression with the given replacement String
replaceAll() Replaces each substring of this string that matches the given regular expression with the given replacement String
split() Splits a string into an array of substrings String[]
startsWith() Checks whether a string starts with specified characters boolean
subSequence() Returns a new character sequence that is a subsequence of this sequence CharSequence
substring() Returns a new string which is the substring of a specified string String
toCharArray() Converts this string to a new character array char[]
toLowerCase() Converts a string to lower case letters String
toString() Returns the value of a String object String
toUpperCase() Converts a string to upper case letters String
trim() Removes whitespace from both ends of a string String
valueOf() Returns the string representation of the specified value String