Posted by Eugene Teo on 1999-11-03
There is hash in java
haha, i wrote this long time ago.......when i started learning java. sucks.
while((s=in.readLine())!=null){
System.out.println(s);
StringTokenizer tokens=new StringTokenizer(s,"|");
num=tokens.nextToken();
model=tokens.nextToken();
brand=tokens.nextToken();
itemcode=tokens.nextToken();
file://Postel=tokens.nextToken();
gifFile=tokens.nextToken();
Double d=Double.valueOf(tokens.nextToken());
price=d.doubleValue();//converting string to double
int tempnum=Integer.parseInt(num);
}
==
eugeneteo@xxxxx.xxx.xx
http://eugeneteo.serverity.com.sg
http://www.linux.com.sg
----- Original Message -----
From: Peter Palfrader aka Weasel <palfrader@xxxxxxx.xxx>
To: <amnesia@xxxxx.xxx.xx>
Sent: Wednesday, November 03, 1999 9:51 AM
Subject: Re: Re: Java
> On Wed, Nov 03, 1999 at 02:37:23AM +0100, Benjamin Johnston wrote:
> > Frank, why don't you email in an particular string manipulation problem
that
> > you have solved using perl, and we can demonstrate how to do that in
Java.
> > That would make it easier to point out the differences between the
> > languages.
>
> I've one:
>
> while ($template =~ /%%([^%]*)%%/) {
> $template =~ s/%%([^%]*)%%/( defined($tmp{$1}) ? $tmp{$1} : '')/ge;
> };
>
>
> %tmp is a hash that stores values for variables. In the string
> $template every occurence of %%var%% is then replaced by the actual
> value of var.
>
> e.g:
>
> $tamplate looks like:
> <html>Hi %%name%%. You are visitor no %%vis_num%%</html>
>
> and %tmp stores those values:
> $tmp{name} = Joe
> $tmp{vis_num} = 2324
>
> After this 3 liner $template looks like this:
> <html>Hi Joe. You are visitor no 2324</html>
>
>
>
> I'm interested how to do this in Java. Is there any equivalent to a
> hash in Java?
>
> --
> Weasel http://www.cosy.sbg.ac.at/~ppalfrad/
> PGP encrypted messages prefered. See my site or finger -l ppalfrad
> > A friend is someone who knows the song in your heart and
> can sing it back to you when you have forgotten the words.
> >
Previous post | Next post | Timeline | Home