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:

kutta

Posted by ravi on January 22, 2002 at 2:45 PM

> I would like to complete this problem in the simplest way possible...
> Generators seem like stuff for hardcore programmers...is it possible to use Wrapper classes and the attributes listed above in solving the problem....????

> P/S(Matt Gerans could u be more specific...as the book seems more likely to confuse me more and make me forget the little I have learnt....)


> > I suppose you could squeek the info into an array of length 27, assuming 'a' is at index 0 and so on (with index 26 being the catch all), but my guess is that your instructor may have intended this to be an exercise in using maps. Maps are often used to solve these categorizing problems. You can easily find such examples in the tutorials. You could also find an example of this exact problem in Bruce Eckel's Thinking in Java book, which you can get online for free at his web site.

> > - mfg

> >
> > > 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...

> > >
> >
saale kya kya puchhata rehtaa hain





Replies:

Sponsored Links



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