#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    52
    Rep Power
    13

    Java equivalent of this Python snippet?


    I need to convert this to Java using multiple for loops.
    Code:
    lines = 15
    stars = 1
    spaces = lines - stars
    while lines != 0:
        print (" " * spaces) + ("*" * stars)
        spaces = spaces - 1
        stars = stars + 2
        lines = lines - 1
    Thanks.
    Last edited by ryankask; September 30th, 2004 at 06:07 PM. Reason: code tags
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Depending on what you want the equivalent Java code for, you might want to look into Jython, an implementation of the Python Interpreter written in Java; that runs under the JVM. With Jython you can compile run the Python program above, and run it using your JVM:

    www.jython.org

    If this isn't what you want you'd probably get a better responce if you reposted your question in the Java forum.

    I hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    52
    Rep Power
    13
    No, I needed it for a class but I've figured it out. Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo