How can I count total chars out of an input string in java or in objective-c?
Hi Friend,
Try the following code:
import java.util.*; class CountCharacters { public static void main(String[] args) throws Exception{ Scanner input=new Scanner(System.in); System.out.print("Please enter string "); String str=input.nextLine(); String st=str.replaceAll(" ", ""); char ch[]=st.toCharArray(); int count=ch.length; System.out.println("Total Characters: "+count); } }
Thanks
Ads