🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: nl.comp.programmeren
Article #554

Re: string converteren naar integer in Java

#554
From: Walter Laan
Date: Mon, 18 Nov 2002 18:42
42 lines
2191 bytes
Passero (yanongena@pandora.be) wrote...
>   int doepoging[] = new int[4];
>   doepoging[0] = 0;
>   doepoging[1] = Integer.parseInt(kl1);
>   doepoging[2] = Integer.parseInt(kl2);
>   doepoging[3] = Integer.parseInt(kl3);
>   doepoging[4] = Integer.parseInt(kl4);

De laatse bestaat niet: Java arrays beginnen bij index 0.

>   int res[] = {0,0,0};

Zou ik gewoon
  int res[] = poging(doepoging);
van maken.

>   int i;

Niet gebruikt of is je echte code iets als:

JTextField kleur [] = new JTextField[4];
> public void actionPerformed(ActionEvent actionEvent)
>  {
>   String commando = actionEvent.getActionCommand();
>   if (commando.equals("Doe een poging"))
>   {
>    int doepoging[] = new int[4];

     for(int i = 0; i<4; i++) {
	try {
         doepoging[i] = Integer.parseInt(kleur[i].getText());
       } catch(NumberFormatException e) {
         System.out.println("Kleurnummer " + i + " is geen nummer!");
         doepoging[i] = 0; // of doe iets anders
       }
     }

     int res[] = poging(doepoging);
>    wit.setText("w: " + Integer.toString(res[2]));
>    zwart.setText("z: " + Integer.toString(res[1]));
>   }
>  }
Technical Details
Message-ID: <MPG.1843530031313d19896aa@localhost>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!isdnet!195.115.0.4.MISMATCH!esplande3000.net!fr.clara.net!heighliner.fr.clara.net!news-x2.support.nl!newsfeed.wxs.nl!transit.news.xs4all.nl!newsfeed.xs4all.nl!xs4all!news.xs4all.nl!not-for-mail
References: <dp8C9.7125$Ti2.1216@afrodite.telenet-ops.be>

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: 107324,478011c6da9508a
X-Google-Attributes: gid107324,public
X-Google-Thread: fcea4,478011c6da9508a
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2002-11-18 11:00:05 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!isdnet!195.115.0.4.MISMATCH!esplande3000.net!fr.clara.net!heighliner.fr.clara.net!news-x2.support.nl!newsfeed.wxs.nl!transit.news.xs4all.nl!newsfeed.xs4all.nl!xs4all!news.xs4all.nl!not-for-mail
X-Posting-Agent: Hamster/1.3.22.104
From: Walter Laan <walterln@xs4all.nl>
Newsgroups: nl.comp.programmeren,be.comp.programming
Subject: Re: string converteren naar integer in Java
Date: Mon, 18 Nov 2002 19:42:33 +0100
Message-ID: <MPG.1843530031313d19896aa@localhost>
References: <dp8C9.7125$Ti2.1216@afrodite.telenet-ops.be>
X-Newsreader: MicroPlanet Gravity v2.60
Lines: 43
NNTP-Posting-Host: 80.127.240.238
X-Trace: 1037644999 news.xs4all.nl 46608 80.127.240.238:1034