Tuesday, 17 November 2020

Write a Program in Java to accept a String and find its length

import java.util.*;

public class Main

{

public static void main(String args[])

{

Scanner in=new Scanner (System.in);

String s; int Length;

System.out.println("Enter a Word");

s=in.next();

Length=s.length();

System.out.println("The length of "+s+" is "+Length);

}

}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...