so, I started working and am supposed to learn java now. I just have a few basic questions, so if u could help me with those that would be great.
1st: What is the constructor and what does it do?
2nd: Is there a general way to tell what is an object and what not?
3rd: What is the signature?
4th: When working with Vectors, what is the Iterator?
5th: I was supposed to write a little app that prints out all prime numbers from 2 to 100. I did a version of it, but it only prints out the number from 10 to 100. I know why it does that, but if u could post a modified or different version of that app it would be great. heres my code:
public class prime2 {
public static void main(String[] args) {
for (int p = 0; p <= 100; p++)
if (p % 2 > 0 && p % 3 > 0 && p % 4 > 0 && p % 5 > 0
&& p % 6 > 0 && p % 7 > 0 && p % 8 > 0 && p % 9 > 0
&& p % 10 > 0) {
System.out.print(p + " ");
}
System.out.println();
}
}
Question
eccofresh
so, I started working and am supposed to learn java now. I just have a few basic questions, so if u could help me with those that would be great.
1st: What is the constructor and what does it do?
2nd: Is there a general way to tell what is an object and what not?
3rd: What is the signature?
4th: When working with Vectors, what is the Iterator?
5th: I was supposed to write a little app that prints out all prime numbers from 2 to 100. I did a version of it, but it only prints out the number from 10 to 100. I know why it does that, but if u could post a modified or different version of that app it would be great. heres my code:
public class prime2 { public static void main(String[] args) { for (int p = 0; p <= 100; p++) if (p % 2 > 0 && p % 3 > 0 && p % 4 > 0 && p % 5 > 0 && p % 6 > 0 && p % 7 > 0 && p % 8 > 0 && p % 9 > 0 && p % 10 > 0) { System.out.print(p + " "); } System.out.println(); } }thx
Link to comment
Share on other sites
9 answers to this question
Recommended Posts