Results 1 to 3 of 3
  1. #1
    Apfelkreis is offline Member
    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Default Why would this code not print out what i want it to ?

    public class Teilung {
    public static void main(String[] arguments) {
    int i,x;
    double gleichnull ;
    gleichnull = 0;
    x = 0;
    for (i= 0; i>100 ; i++){
    x = x + 1 ;
    if ( gleichnull == x % 3 ){
    System.out.println(x);
    }


    }
    }
    }


    Sorry for the horrible formatting,im new! It's supposed to print out every number that is possible to divide by three,but it doesnt do anything. Syntax errors are not involved,since i already compiled it

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default Re: Why would this code not print out what i want it to ?

    Have a close look at your for-loop condition (the loop body never runs).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    tech.sol18 is offline Member
    Join Date
    Aug 2013
    Posts
    2
    Rep Power
    0

    Default Re: Why would this code not print out what i want it to ?

    please check your for loop. The condition in the for loop is i>100, but i=0. So condition is returning false. and coming out of the loop.

Similar Threads

  1. When would this code print out....
    By icykum in forum New To Java
    Replies: 3
    Last Post: 11-26-2012, 02:40 AM
  2. Why is the spacing so odd when I print this code?
    By HalfAZN in forum New To Java
    Replies: 5
    Last Post: 10-10-2012, 12:02 AM
  3. Code Print Error! Help needed
    By socboy6579 in forum New To Java
    Replies: 13
    Last Post: 11-16-2010, 03:35 AM
  4. How to use and print the JAVA code from a JSP
    By Ginkan in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-23-2010, 02:05 PM
  5. Replies: 11
    Last Post: 04-16-2008, 01:52 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
  •