Discussione: [Jdev] Assertion
View Single Post
Old 23-06-2005, 12:24   #1
Sirbako
Senior Member
 
L'Avatar di Sirbako
 
Iscritto dal: Oct 2004
Cittā: Rovereto (tn)
Messaggi: 2187
[Jdev] Assertion

come si fa ad abilitare le assertioni in jdev?
Ho questo codice (č il testo di un es dell'esame di oggi, che nn ho passato) e devo controllare cosa fa. Solo che nn compila.
Codice:
package esame;
public class es1 
{
int x=5;
public void stampaint(int i)
{
  assert i>=0: stampaerr();
  System.out.println(i);
}
public int stampaerr()
{
  System.out.println("XX");
  return -1;
}

  public static void main(String[] args)
  {
  int x=10;
    es1 e = new es1();
    e.stampaint(x);
  }
}
errori:
Error(8,11): ';' expected
Error(8,3): class assert not found in class esame.es1
Error(8,10): duplicate definition of variable i in method stampaint(int)
Warning(8,3): 'assert' is a keyword in J2SE 1.4, should not be used as an identifier
la riga 8 č
Codice:
  assert i>=0: stampaerr();
__________________

Esse.Ti.?!?
Sirbako č offline   Rispondi citando il messaggio o parte di esso