Tech Jargon - Decoded
Ir al canal en Telegram
Confused by tech terms? Don’t worry, we’ve got you 🤝 We make things simple, one concept at a time. Learn daily Easy & clear Turn Confusion into clarity. #tech #it #softwareengineer #cs #development
Mostrar más2 018
Suscriptores
Sin datos24 horas
-77 días
-4030 días
Archivo de publicaciones
💻 Toggle Case of Each Character
import java.util.Scanner;
public class ToggleCase {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
String toggledString = "";
for (int i = 0; i < inputString.length(); i++) {
char currentChar = inputString.charAt(i);
if (Character.isUpperCase(currentChar)) {
toggledString += Character.toLowerCase(currentChar);
} else if (Character.isLowerCase(currentChar)) {
toggledString += Character.toUpperCase(currentChar);
} else {
toggledString += currentChar;
}
}
System.out.println("Toggled case string: " + toggledString);
scanner.close();
}
}
📤 Output:
Input: Hello World Output: Toggled case string: hELLO wORLD Input: Java123 Output: Toggled case string: jAVA123 Input: MiXeD CaSe Output: Toggled case string: mIxEd cAsE
💻 Capitalize First Letter of Each Word
import java.util.Scanner;
public class CapitalizeFirstLetter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a string: ");
String inputString = scanner.nextLine();
String capitalizedString = capitalizeEachWord(inputString);
System.out.println("Capitalized string: " + capitalizedString);
scanner.close();
}
public static String capitalizeEachWord(String input) {
String[] words = input.split(" ");
StringBuilder result = new StringBuilder();
for (String word : words) {
if (!word.isEmpty()) {
// Capitalize the first letter
char firstChar = Character.toUpperCase(word.charAt(0));
String remainingLetters = word.substring(1).toLowerCase(); // Convert remaining to lowercase
result.append(firstChar).append(remainingLetters).append(" "); //Append word to result
}
}
return result.toString().trim(); //remove trailing space
}
}
📤 Output:
Input: hello world Output: Enter a string: Capitalized string: Hello World Input: this is a test STRING Output: Enter a string: Capitalized string: This Is A Test String Input: extra spaces Output: Enter a string: Capitalized string: Extra Spaces Input: 123 abc Output: Enter a string: Capitalized string: 123 Abc Input: Output: Enter a string: Capitalized string:
💻 Check if String Contains Only Alphabet
import java.util.Scanner;
public class StringContainsOnlyAlphabet {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
boolean containsOnlyAlphabet = true;
for (int i = 0; i < inputString.length(); i++) {
char ch = inputString.charAt(i);
if (!Character.isLetter(ch)) {
containsOnlyAlphabet = false;
break;
}
}
if (containsOnlyAlphabet) {
System.out.println("The string contains only alphabets.");
} else {
System.out.println("The string does not contain only alphabets.");
}
scanner.close();
}
}
📤 Output:
Input: HelloWorld Output: The string contains only alphabets. Input: Hello World Output: The string does not contain only alphabets. Input: Alphabet123 Output: The string does not contain only alphabets. Input: ABCDEFG Output: The string contains only alphabets. Input: abcdefg Output: The string contains only alphabets. Input: Output: The string contains only alphabets. Input: !@#$%^ Output: The string does not contain only alphabets. Input: Hello! Output: The string does not contain only alphabets. Input: Output: The string does not contain only alphabets.
💻 Check if String Contains Only Digits
import java.util.Scanner;
public class StringContainsOnlyDigits {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
boolean onlyDigits = true;
for (int i = 0; i < inputString.length(); i++) {
if (!Character.isDigit(inputString.charAt(i))) {
onlyDigits = false;
break;
}
}
if (onlyDigits) {
System.out.println("The string contains only digits.");
} else {
System.out.println("The string does not contain only digits.");
}
scanner.close();
}
}
📤 Output:
Input: 12345 Output: The string contains only digits. Input: abc123 Output: The string does not contain only digits. Input: 9876543210 Output: The string contains only digits. Input: 123.45 Output: The string does not contain only digits. Input: Output: The string contains only digits.
💻 Replace Character in String
import java.util.Scanner;
public class ReplaceCharacterInString {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the string: ");
String inputString = scanner.nextLine();
System.out.print("Enter the character to replace: ");
char charToReplace = scanner.next().charAt(0);
System.out.print("Enter the replacement character: ");
char replacementChar = scanner.next().charAt(0);
String replacedString = inputString.replace(charToReplace, replacementChar);
System.out.println("Original string: " + inputString);
System.out.println("Replaced string: " + replacedString);
scanner.close();
}
}
📤 Output:
Input: Hello World Input: l Input: z Output: Original string: Hello World Output: Replaced string: Hezzo Worzd
💻 Find Last Occurrence of Character
import java.util.Scanner;
public class LastOccurrenceOfCharacter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the string: ");
String inputString = scanner.nextLine();
System.out.print("Enter the character to find: ");
char charToFind = scanner.next().charAt(0);
int lastIndex = -1;
for (int i = 0; i < inputString.length(); i++) {
if (inputString.charAt(i) == charToFind) {
lastIndex = i;
}
}
if (lastIndex != -1) {
System.out.println("Last occurrence of '" + charToFind + "' is at index: " + lastIndex);
} else {
System.out.println("Character '" + charToFind + "' not found in the string.");
}
scanner.close();
}
}
📤 Output:
Input: Hello World Input: l Output: Last occurrence of 'l' is at index: 9 Input: Banana Input: a Output: Last occurrence of 'a' is at index: 5 Input: Open AI Input: z Output: Character 'z' not found in the string.
💻 Find First Occurrence of Character
import java.util.Scanner;
public class FindFirstOccurrence {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the string: ");
String inputString = scanner.nextLine();
System.out.print("Enter the character to find: ");
char charToFind = scanner.next().charAt(0);
int firstOccurrenceIndex = -1; // Initialize with -1 in case the character is not found
for (int i = 0; i < inputString.length(); i++) {
if (inputString.charAt(i) == charToFind) {
firstOccurrenceIndex = i;
break; // Exit the loop after finding the first occurrence
}
}
if (firstOccurrenceIndex != -1) {
System.out.println("First occurrence of '" + charToFind + "' is at index: " + firstOccurrenceIndex);
} else {
System.out.println("Character '" + charToFind + "' not found in the string.");
}
scanner.close();
}
}
📤 Output:
Input: Hello World Input: l Output: First occurrence of 'l' is at index: 2 Input: Banana Input: a Output: First occurrence of 'a' is at index: 1 Input: OpenAI Input: z Output: Character 'z' not found in the string.
💻 Remove All Whitespaces from String
import java.util.Scanner;
public class RemoveWhiteSpaces {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
String stringWithoutSpaces = inputString.replaceAll("\s+", ""); // \s+ matches one or more whitespace characters
System.out.println("String without whitespaces: " + stringWithoutSpaces);
scanner.close();
}
}
📤 Output:
Input: Hello World! Output: String without whitespaces: HelloWorld! Input: This is a test string. Output: String without whitespaces: Thisisateststring. Input: Multiple spaces here. Output: String without whitespaces: Multiplespaceshere. Input: NoSpacesHere Output: String without whitespaces: NoSpacesHere Input: Output: String without whitespaces:
💻 Check if Two Strings are Anagrams
import java.util.Arrays;
import java.util.Scanner;
public class AnagramChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first string: ");
String firstString = scanner.nextLine();
System.out.print("Enter second string: ");
String secondString = scanner.nextLine();
boolean areAnagrams = checkIfAnagrams(firstString, secondString);
if (areAnagrams) {
System.out.println("The strings are anagrams.");
} else {
System.out.println("The strings are not anagrams.");
}
scanner.close();
}
public static boolean checkIfAnagrams(String str1, String str2) {
// Remove spaces and convert to lowercase for case-insensitive comparison
str1 = str1.replaceAll("\s", "").toLowerCase();
str2 = str2.replaceAll("\s", "").toLowerCase();
// Check if lengths are equal
if (str1.length() != str2.length()) {
return false;
}
// Convert strings to char arrays and sort them
char[] charArray1 = str1.toCharArray();
char[] charArray2 = str2.toCharArray();
Arrays.sort(charArray1);
Arrays.sort(charArray2);
// Compare the sorted arrays
return Arrays.equals(charArray1, charArray2);
}
}
📤 Output:
Input: listen Input: silent Output: The strings are anagrams. Input: hello Input: world Output: The strings are not anagrams. Input: Dormitory Input: dirty room Output: The strings are anagrams. Input: racecar Input: race car Output: The strings are anagrams.
💻 Count Words in a String
import java.util.Scanner;
public class WordCounter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
// Split the string by spaces to count words
String[] words = inputString.split(" ");
// Count the number of words
int wordCount = 0;
for (String word : words) {
if (!word.isEmpty()) { // Ignore empty strings
wordCount++;
}
}
System.out.println("Number of words: " + wordCount);
scanner.close();
}
}
📤 Output:
Input: The quick brown fox jumps over the lazy dog. Output: Enter a string: Number of words: 9 Input: Hello world Output: Enter a string: Number of words: 2 Input: This is a test. Output: Enter a string: Number of words: 4 Input: Output: Enter a string: Number of words: 0 Input: One Two Three Output: Enter a string: Number of words: 3
💻 Convert String to Lowercase
import java.util.Scanner;
public class StringToLowercase {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
String lowercaseString = inputString.toLowerCase();
System.out.println("Lowercase string: " + lowercaseString);
scanner.close();
}
}
📤 Output:
Input: HeLlO wOrLd Output: Lowercase string: hello world
💻 Convert String to Uppercase
import java.util.Scanner;
public class StringToUppercase {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
String uppercaseString = inputString.toUpperCase();
System.out.println("Uppercase string: " + uppercaseString);
scanner.close();
}
}
📤 Output:
Input: hello world Output: Uppercase string: HELLO WORLD Input: Java Programming Output: Uppercase string: JAVA PROGRAMMING Input: 12345 Output: Uppercase string: 12345 Input: mixedCase Output: Uppercase string: MIXEDCASE Input: Output: Uppercase string:
💻 Compare Two Strings
import java.util.Scanner;
public class CompareTwoStrings {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the first string: ");
String firstString = scanner.nextLine();
System.out.print("Enter the second string: ");
String secondString = scanner.nextLine();
if (firstString.equals(secondString)) {
System.out.println("The two strings are equal.");
} else {
System.out.println("The two strings are not equal.");
}
scanner.close();
}
}
📤 Output:
Input: Hello Input: Hello Output: The two strings are equal. Input: Hello Input: World Output: The two strings are not equal. Input: Java Input: java Output: The two strings are not equal.
💻 Reverse a String
import java.util.Scanner;
public class ReverseString {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
String reversedString = new StringBuilder(inputString).reverse().toString();
System.out.println("Reversed string: " + reversedString);
scanner.close();
}
}
📤 Output:
Input: Hello, World! Output: Reversed string: !dlroW ,olleH Input: Java Output: Reversed string: avaJ Input: madam Output: Reversed string: madam
💻 Check if String is Palindrome
import java.util.Scanner;
public class PalindromeChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
if (isPalindrome(inputString)) {
System.out.println("The string is a palindrome.");
} else {
System.out.println("The string is not a palindrome.");
}
scanner.close();
}
public static boolean isPalindrome(String str) {
String cleanString = str.replaceAll("\s+", "").toLowerCase(); // Remove spaces and convert to lowercase
int left = 0;
int right = cleanString.length() - 1;
while (left < right) {
if (cleanString.charAt(left) != cleanString.charAt(right)) {
return false; // Not a palindrome
}
left++;
right--;
}
return true; // It's a palindrome
}
}
📤 Output:
Input: Racecar Output: The string is a palindrome. Input: A man, a plan, a canal: Panama Output: The string is a palindrome. Input: hello Output: The string is not a palindrome. Input: Was it a car or a cat I saw? Output: The string is a palindrome. Input: level Output: The string is a palindrome. Input: madam Output: The string is a palindrome. Input: rotor Output: The string is a palindrome. Input: stats Output: The string is a palindrome. Input: step on no pets Output: The string is a palindrome. Input: Able was I ere I saw Elba Output: The string is a palindrome.
💻 Count Digits and Special Characters in String
import java.util.Scanner;
public class CountDigitsAndSpecialChars {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
int digitCount = 0;
int specialCharCount = 0;
for (int i = 0; i < inputString.length(); i++) {
char ch = inputString.charAt(i);
if (Character.isDigit(ch)) {
digitCount++;
} else if (!Character.isLetterOrDigit(ch) && !Character.isWhitespace(ch)) {
specialCharCount++;
}
}
System.out.println("Number of digits: " + digitCount);
System.out.println("Number of special characters: " + specialCharCount);
scanner.close();
}
}
📤 Output:
Input: Hello World! 123 @#$ Output: Enter a string: Number of digits: 3 Number of special characters: 3
💻 Count Vowels and Consonants in a String
import java.util.Scanner;
public class VowelConsonantCounter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
int vowelCount = 0;
int consonantCount = 0;
inputString = inputString.toLowerCase();
for (int i = 0; i < inputString.length(); i++) {
char ch = inputString.charAt(i);
if (ch >= 'a' && ch <= 'z') {
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
vowelCount++;
} else {
consonantCount++;
}
}
}
System.out.println("Vowels: " + vowelCount);
System.out.println("Consonants: " + consonantCount);
scanner.close();
}
}
📤 Output:
Input: Hello World Output: Enter a string: Vowels: 3 Output: Consonants: 7
💻 Calculate Length of String
import java.util.Scanner;
public class StringLengthCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
int stringLength = inputString.length();
System.out.println("The length of the string is: " + stringLength);
scanner.close();
}
}
📤 Output:
Input: Hello, World! Output: Enter a string: The length of the string is: 13 Input: This is a test. Output: Enter a string: The length of the string is: 15 Input: Output: Enter a string: The length of the string is: 0 Input: Java Output: Enter a string: The length of the string is: 4 Input: 12345 Output: Enter a string: The length of the string is: 5
💻 Search in Row-wise and Column-wise Sorted Matrix
import java.util.Scanner;
public class SearchSortedMatrix {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of rows: ");
int rows = scanner.nextInt();
System.out.print("Enter the number of columns: ");
int cols = scanner.nextInt();
int[][] matrix = new int[rows][cols];
System.out.println("Enter the elements of the matrix (row-wise):");
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
matrix[i][j] = scanner.nextInt();
}
}
System.out.print("Enter the element to search: ");
int key = scanner.nextInt();
int row = 0;
int col = cols - 1;
boolean found = false;
while (row < rows && col >= 0) {
if (matrix[row][col] == key) {
System.out.println("Element found at row: " + (row + 1) + ", column: " + (col + 1));
found = true;
break;
} else if (matrix[row][col] < key) {
row++;
} else {
col--;
}
}
if (!found) {
System.out.println("Element not found in the matrix.");
}
scanner.close();
}
}
📤 Output:
Input: 3 Input: 3 Input: 1 Input: 4 Input: 7 Input: 2 Input: 5 Input: 8 Input: 3 Input: 6 Input: 9 Input: 5 Output: Element found at row: 2, column: 2 Input: 2 Input: 2 Input: 10 Input: 20 Input: 30 Input: 40 Input: 35 Output: Element not found in the matrix.
¡Ya disponible! Investigación de Telegram 2025 — los principales insights del año 
