Posts

Showing posts from July, 2025

Wrapper methods programs

 Here are Java programs based on wrapper classes and their methods , showing only input and output : ✅ 1. Convert String to int Input: "123" Output: 133 String s = "123"; int num = Integer.parseInt(s); System.out.println(num + 10); ✅ 2. String to Integer object Input: "456" Output: 912 String s = "456"; Integer obj = Integer.valueOf(s); System.out.println(obj * 2); ✅ 3. Check if char is digit Input: '5' Output: It's a digit. char c = '5'; if(Character.isDigit(c)) { System.out.println("It's a digit."); } ✅ 4. Check if char is letter Input: 'a' Output: true char ch = 'a'; System.out.println(Character.isLetter(ch)); ✅ 5. Convert upper to lower Input: 'A' Output: 'a' char upper = 'A'; System.out.println(Character.toLowerCase(upper)); ✅ 6. Convert lower to upper Input: 'm' Output: 'M' char lower = 'm'; System....

Java string manipulation program titles, now with sample inputs :

L ist of 100 real-time Java string manipulation program titles , now with sample inputs  : 🔐 Authentication & Tokens Extract token value from API response string 🔸 Input: "token=abc123xyz; sessionId=xyz456;" Extract only digits from a token string 🔸 Input: "token=45gh6ab78;" Parse JWT and extract payload 🔸 Input: "eyJhbGci...eyJ1c2VyIjoiam9obiJ9..." Extract session ID from cookie string 🔸 Input: "JSESSIONID=58DFA0A2B54D5E85F39D;" Validate Bearer token format 🔸 Input: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." Remove prefix from access token 🔸 Input: "access_token=abc123xyz" Split authorization header into type and value 🔸 Input: "Basic YWxhZGRpbjpvcGVuc2VzYW1l" Check if token is expired using timestamp in string 🔸 Input: "exp=1718918400;" Parse OAuth callback URL and extract code 🔸 Input: "https://example.com/callback?code=12345abc" Extr...

String manipulation and character-based logic:

String  manipulation and character-based logic: 🔢 String Parsing and Extraction Extract all digits from a given string. Extract all letters from a string. Extract only uppercase letters from a string. Extract only lowercase letters from a string. Extract special characters from a string. Extract digits and return as an integer array. Extract words separated by a comma. Extract domain from an email string. Extract username from an email string. Extract numbers from a string and calculate their sum. 🔁 String Modification Replace all digits with * . Replace all vowels with # . Remove all spaces from a string. Remove duplicate characters from a string. Replace all occurrences of a word. Replace each character with its ASCII value. Replace uppercase letters with lowercase and vice versa. Insert a dash between every two digits. Add commas after every 3 digits in a number string. Format a string like a phone number: (123)...

String program

Here is a list of 10 interview-style Java programs for each of the 20 commonly used String methods . These can help you prepare effectively: ✅ 1. length() Check if a string is empty without using isEmpty() . Count the number of characters in a sentence. Validate if input length is less than 10 characters. Compare lengths of two strings. Trim string and compare original vs trimmed length. Count total characters excluding spaces. Calculate total length of all words in a sentence. Validate password length (e.g., min 8 chars). Get length of each word in a string. Find average length of words in sentence. ✅ 2. charAt() Find first and last character of a string. Count occurrences of a specific character. Print characters at even positions. Replace character at given index. Reverse string using charAt() . Count uppercase and lowercase letters. Check if all characters are digits. Print ASCII value of each character. Find vowels and their positions. Print alternate ...

commonly used String methods in Java,

Here's a complete list of commonly used String methods in Java , along with what they do and how to use them in programming : ✅ 1. length() Returns the number of characters in the string. String str = "Java"; System.out.println(str.length()); // 4 ✅ 2. charAt(int index) Returns the character at the given index (0-based). System.out.println(str.charAt(1)); // 'a' ✅ 3. substring(int startIndex) Returns substring from given index to end. System.out.println(str.substring(1)); // "ava" ✅ 4. substring(int start, int end) Returns substring from start to (end - 1). System.out.println(str.substring(1, 3)); // "av" ✅ 5. indexOf(char/String) Finds the index of first occurrence of character/substring. System.out.println(str.indexOf('a')); // 1 ✅ 6. lastIndexOf(char/String) Finds the index of last occurrence of character/substring. System.out.println(str.lastIndexOf('a')); // 3 ✅ 7. toLowerCase() / toUpp...