Java Question

  • Java
  • Thread starter JasonRox
  • Start date
  • #1
JasonRox
Homework Helper
Gold Member
2,314
3
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.
 

Answers and Replies

  • #2
dduardo
Staff Emeritus
1,890
3
Create as big of an array as you like.

int X = 1000 ;

boolean [] p = new boolean[X];
 
  • #3
JasonRox
Homework Helper
Gold Member
2,314
3
Thanks a lot.

I'll see how it turns out.
 

Related Threads on Java Question

  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
5
Views
4K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
4
Views
1K
  • Last Post
2
Replies
28
Views
2K
Replies
2
Views
1K
Replies
6
Views
3K
Replies
11
Views
2K
Top