Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java Question

  1. Apr 5, 2006 #1

    JasonRox

    User Avatar
    Homework Helper
    Gold Member

    I'm trying to create a sieve (prime sieve). A nice quick simple one using boolean expressions.

    I remember on Visual Basics it began by creating like X number of boolean variables and then sieve them out by classifying them as false... and so on.

    How to a create a large group of boolean variables?

    I think it was something like p(i) and i=X, which X determined how many to create. It was something like this I think.

    So, technically i is like a variable itselt because when I go through the loop, I should be able to go through steps like...

    p(4) = false;
    p(6) = false;
    p(8) = false;

    ... all the way until I reach 2X.

    So, how do you create this variable?

    Thanks, I appreciate it.
     
  2. jcsd
  3. Apr 5, 2006 #2

    dduardo

    User Avatar
    Staff Emeritus

    Create as big of an array as you like.

    int X = 1000 ;

    boolean [] p = new boolean[X];
     
  4. Apr 5, 2006 #3

    JasonRox

    User Avatar
    Homework Helper
    Gold Member

    Thanks a lot.

    I'll see how it turns out.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Java Question
  1. Java Question (Replies: 2)

  2. Java question (Replies: 5)

  3. Java Question (Replies: 3)

  4. Question about Java (Replies: 4)

Loading...