Pankaj-Str's GitHub, 'JAVA-SE-Tutorial-codeswithpankaj,' is a concise compendium of Java SE tutorials. Ideal for developers and learners, it offers clear and insightful code snippets, providing an efficient pathway to enhance Java programming skills. A valuable resource for mastering essential concepts
// Importing required libraries
import java.io.*;
import java.util.*;
// Class
class GFG {
// Main driver method
public static void main(String[] args)
{
String str = " Geeks for Geeks ";
String op = "";
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
// Checking whether is white space or not
if (!Character.isWhitespace(ch)) {
op += ch;
}
}
System.out.println(op);
}
}