logo

שיטת Java Character toUpperCase()

ה toUpperCase(char ch) השיטה של ​​מחלקה Character ממירה את ארגומנט התווים הנתון לאותיות רישיות באמצעות מידע מיפוי רישיות המסופק על ידי קובץ Unicode Data.

יש לציין ש-Character.isUpperase(Character.UpperCase(ch)) לא תמיד יחזיר נכון עבור תווים מסוימים.

למעשה, ניתן להשתמש ב-String.toUpperCase() כדי למפות את התווים באותיות רישיות. ישנם יתרונות שונים של מיפוי מקרה של מחרוזת בהשוואה למיפוי מקרה של תווים. ניתן להשתמש במיפוי אירועי מחרוזת לביצוע מיפויים רגישים מקומיים, מיפויים רגישים להקשר בעוד שלא ניתן להשתמש במיפוי אירועי תווים.

תחביר

 public static char toUpperCase(char ch) 

פָּרָמֶטֶר

ch : הדמות היא שצריך להמיר.

ערך החזרה

שיטת toUpperCase(char ch) מחזירה את האותיות הגדולות של התו הנתון. אחרת, שיטה זו מחזירה את התו עצמו.

דוגמה 1

 public class JavaCharacterToUpperCaseExample1 { public static void main(String[] args) { // Create four char primitives. char ch1, ch2, ch3, ch4; // Assign the values to ch1 and ch2. ch1 = 'm'; ch2 = 'q'; // Assign the uppercase of ch1 and ch2 to ch3 and ch4 respectively. ch3 = Character.toUpperCase(ch1); ch4 = Character.toUpperCase(ch2); String str1 = 'The uppercase of the character '' + ch1 + '' is given as: ' + ch3; String str2 = 'The uppercase of the character '' + ch2 + '' is given as: ' + ch4; // Print the values of ch1 and ch2. System.out.println( str1 ); System.out.println( str2 ); } } 
בדוק את זה עכשיו

תְפוּקָה:

 The titlecase of character 'm' is given as: M The titlecase of character 'q' is given as: Q 

דוגמה 2

 public class JavaCharacterToUpperCaseExample2{ public static void main(String[] args) { // Create four char primitives. char ch1, ch2, ch3, ch4; // Assign the values to ch1 and ch2. ch1 = '+'; ch2 = 'f'; // Assign the uppercase of ch1 and ch2 to ch3 and ch4 respectively. ch3 = Character.toUpperCase(ch1); ch4 = Character.toUpperCase(ch2); String str1 = 'The uppercase of the character '' + ch1 + '' is given as: ' + ch3; String str2 = 'The uppercase of the character '' + ch2 + '' is given as: ' + ch4; // Print the values of ch1 and ch2.. System.out.println( str1 ); System.out.println( str2 ); } } 
בדוק את זה עכשיו

תְפוּקָה:

 The uppercase of the character '+' is given as: + The uppercase of the character 'F' is given as: F 


שיטת Java Character toUpperCase(int codePoint).

ה toUpperCase(int codePoint) השיטה של ​​מחלקה Character ממירה את ארגומנט התווים הנתון (נקודת קוד Unicode) לאותיות רישיות באמצעות מידע מיפוי רישיות המסופק על ידי קובץ Unicode Data.

יש לציין ש-Character.isUpperase(Character.UpperCase(codePoint)) לא תמיד יחזיר true עבור תווים מסוימים.

למעשה, ניתן להשתמש ב-String.toUpperCase() כדי למפות את התווים באותיות רישיות. ישנם יתרונות שונים של מיפוי מקרה של מחרוזת בהשוואה למיפוי מקרה של תווים. ניתן להשתמש במיפוי אירועי מחרוזת לביצוע מיפויים רגישים מקומיים, מיפויים רגישים להקשר בעוד שלא ניתן להשתמש במיפוי אירועי תווים.

תחביר

 public static int toUpperCase(int codePoint) 

פָּרָמֶטֶר

codePoint : זה ה-codePoint שהוא הדמות שצריך להיבדק.

ערך החזרה

השיטה toUpperCase(int codePoint) מחזירה את האותיות הגדולות של התו הנתון (נקודת קוד Unicode). אחרת, שיטה זו מחזירה את התו עצמו.

דוגמה 1

 public class JavaCharactertoUpperCaseExample_1 { public static void main(String[] args) { // Initialize two char primitives. int codepoint1 = 102; int codepoint2 = 110; // Convert the codepoints to char type. char ch1 = (char) codepoint1; char ch2 = (char) codepoint2; // Convert the codepoints to uppercase. char upper1 = Character.toUpperCase(ch1); char upper2 = Character.toUpperCase(ch2); // Print the result. System.out.println('The uppercase for the character '' + ch1 + '' is given as: ' + upper1); System.out.println('The uppercase for the character '' + ch2 + '' is given as: ' + upper2); } } 
בדוק את זה עכשיו

תְפוּקָה:

 The uppercase for the character 'f' is given as: F The uppercase for the character 'n' is given as: N 

דוגמה 2

 public class JavaCharactertoUpperCaseExample_2 { public static void main(String[] args) { // Initialize two char primitives. int codepoint1 = 119; int codepoint2 = 80; // Convert the codepoints to char type. char ch1 = (char) codepoint1; char ch2 = (char) codepoint2; // Convert the codepoints to uppercase. char upper1 = Character.toUpperCase(ch1); char upper2 = Character.toUpperCase(ch2); // Print the result. String str1 = 'The uppercase for the character '' + ch1 + '' is given as: ' + upper1; String str2 = 'The uppercase for the character '' + ch2 + '' is given as: ' + upper2; System.out.println(str1); System.out.println(str2); } } 
בדוק את זה עכשיו

תְפוּקָה:

 The uppercase for the character 'w' is given as: W The uppercase for the character 'P' is given as: P