I wanna know how to print only part of a string.
For instance:

public static void main(String[] args){
        
       String a = "daniweb.com";
       System.out.println(a);
}

I wanna say print only characters after the 4th one
so the output would be:

> web.com

Look up the substring() method of the String class.

and before that check for null and isEmpty

if (a != null && a.length() > 0) {
   // some subString
}

Actually isEmpty isn't enough, the String needs to be longer than what is being stripped off the front.

Thanks for help guys substring() worked . xD i love u

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.