The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

CharAt()...and indexOf()....and Arrays

Posted by peter on November 10, 2001 at 12:41 PM

I'm new to programming and I'm writting a program..that is supposed to capture the value...command line... a user inputs and checks that word for all the characters and displays them as an array...

i.e. java CommandLine "all java applications contains a static main method."

produces
letter Freq
===== ===
a 9
c 3
d 1
e 1
h 1
i 5
j 1
l 3
m 2
n 4
o 3
p 2
s 3
t 5
v 1
others 10

The code I have so far...
class CommandLine{

// MY PROBLEM HOW TO USE THE STRING ATTRIBUTES AND ARRAY ATTRIBUTES
// so how would i implement it in this method?
//This being a class that gets the value the user entered as a
command line arguments........
public int [] freq(String s)
{

for(int i = 0; i
char chr = s.charAt(i);//returns char value
int indexOf = s.indexOf(i); //returns position....

What should I do before I can call the method to main?????
Anyone have ideas...






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us