Results 1 to 5 of 5
  1. #1
    poop is offline Member
    Join Date
    May 2011
    Posts
    1
    Rep Power
    0

    Default Dividing in java

    hi i was trying to divide like this

    if (i/i=1)&&(i%i=0)


    but i get an error, illegal start of expression


    any help is good
    thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    that's not valid Java, for one you need to use == to check for equivalence, not =. Next you'll want your entire boolean portion of the if wrapped in parenthesis.

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    = is assignment
    == is comparison

    Also you need to place round brackets around your entire conditional statement.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    OK, I'll bite. Just *what* are you trying to do?

    I mean you divide with foo/bar. But what is the i/i==1 etc business supposed to do?
    Last edited by pbrockway2; 05-30-2011 at 07:33 AM.

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Quote Originally Posted by pbrockway2 View Post
    OK, I'll bite. Just *what* are you trying to do?
    Yeah, it would be interesting. Once the syntax is corrected it is impossible for the if statement to ever be false.

Similar Threads

  1. Dividing in Java
    By hawaiifiver in forum New To Java
    Replies: 19
    Last Post: 03-11-2011, 11:09 AM
  2. Dividing 3 items, please help.
    By Quizzle23 in forum New To Java
    Replies: 18
    Last Post: 02-24-2011, 06:42 AM
  3. Replies: 2
    Last Post: 10-28-2010, 01:56 PM
  4. Java source code for Dividing a file
    By LOKESHWARI in forum Advanced Java
    Replies: 2
    Last Post: 10-14-2010, 03:27 PM
  5. dividing video files into frames..
    By swathi palla in forum AWT / Swing
    Replies: 0
    Last Post: 02-15-2009, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •