Java String Methods

String length() method

In java if we want to get the length of the input String then use length() method on that string.



public class LengthDemo {

      public static void main(String[] args) {

            String name = "Rajneesh";
            System.out.println("length Rajneesh="+ name.length());

            String fullName = "Mukesh Tiwari";
            System.out.println("length Mukesh Tiwari="+ fullName.length());




length Rajneesh=8

length Mukesh Tiwari=13

Please Share this page
Views : 129
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!