> hi, all:
> got a question:
> following is an exam.
>
> class Prob2 {
> public static void main (String [] args) {
> int arr[]=new int[args.length];
> float var1=0;
>
> for (int i=0;i<args.length;i++)
> arr[i]=(new Integer(args[i])).intValue();
> for (int i=0;i<arr.length;i++)
> var1=(i%2==0)?0:arr[i];
> System.out.println(var1/args.length);
> }
> }
>
>
> what is result when you run:
> java Prob2 20 45 60 85 100 205 300 405
>
> I don't understand what it is meaning that "var1=(i%2==0)?0:arr[i];"
> who can explain it to me?
>
> thanks.
>
> sincerely
> sun
>
> ----------
> From: Chong Yu Meng[SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, November 10, 1999 2:20 PM
> To: Sun JunXu
> Subject: Re: java operator
>
> What the hell ? Is this a quiz or something ?
>
> I think what you are seeing here is obfuscated code.
>
> i%2 means i can take any value from 0 to 2
> i%2==0 means : is i%2 the value "0" ?
> I don't know what ":" means, though it is listed as a conditional
> operator.
> arr[i] means the ith member of array arr.
>
> Regards,
> chong
>
> Sun JunXu wrote:
>
> > thank you very much.
> > it is enough, I think you are better than that book.
> > ok, one question:
> >
> > var1 = (i%2==0)?0:arr[i];
> > what does it mean?
> >
> > thanks a lot.
> >
> > sun
> >
> > > ----------
> > > From: Chong Yu Meng[SMTP:[EMAIL PROTECTED]]
> > > Sent: Wednesday, November 10, 1999 11:32 AM
> > > To: Sun JunXu
> > > Subject: Re: java operator
> > >
> > > I would highly recommend the book "Thinking in Java". They have a very
> > > good
> > > explanation of operators with Java examples.
> > >
> > > Anyway, very briefly,
> > >
> > > % means 'modulus'. That means, if a number has decimal places (eg.
> > > 7.2345),
> > > it will give the whole number (eg. 7). No rounding up or down. Just
> the
> > > whole
> > > number
> > >
> > > /= means 'something divide by something and put into something'.
> > > In other words :
> > > x = x/y can be re-written as x /= y
> > > Similarly,
> > > x = x+y is the same as x += y
> > > x = x - y is the same as x -= y
> > > and so on...
> > >
> > > Anyway, just read the book. Or you can give me a list of operators and
> > > I'll
> > > see what I can do with it...
> > >
> > > Regards,
> > > chong
> > >
> > > Sun JunXu wrote:
> > >
> > > > sorry for my lazy mail.
> > > > I have known some operators following
> > > > 3.12 Operators
> > > > The following 37 tokens are the Java operators, formed from ASCII
> > > > characters:
> > > > Operator: one of
> > > > = > < ! ~ ? :
> > > > == <= >= != && || ++
> > > --
> > > > + - * / & | ^
> > > %
> > > > << >> >>>
> > > > += -= *= /= &= |= ^=
> > > %=
> > > > <<= >>= >>>=
> > > >
> > > > but some ones like as %, /=, I don't know how to use.
> > > >
> > > > sun
> > > >
> > > > > ----------
> > > > > From: Chong Yu Meng[SMTP:[EMAIL PROTECTED]]
> > > > > Sent: Wednesday, November 10, 1999 11:09 AM
> > > > > To: Sun JunXu
> > > > > Subject: Re: java operator
> > > > >
> > > > > Not sure I understand your question, Sun. What kind of operator
> are
> > > you
> > > > > looking for ? Mathematical operators? They're the usual : addition
> > > (+),
> > > > > subtraction (-), etc. Relational operators ? They're greater than
> > > (>),
> > > > > less
> > > > > than (<), etc.
> > > > >
> > > > >
> > > > >
> > > > > Sun JunXu wrote:
> > > > >
> > > > > > Chong:
> > > > > > do you have a specification of java operator? I can't find
> anything
> > > > > about
> > > > > > it.
> > > > > >
> > > > > > thanks.
> > > > > >
> > > > > > sincerely
> > > > > > sun
> > > > >
> > >
>
>
>
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]