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 : 58