Problems encountered in learning Java basics

Source: Internet
Author: User

In this week's basic Java learning, I discovered many of its own problems.

1. The teacher will appear in the study of the confusion of knowledge, not clear or suspect is not the case. For example, in the question of the number of problems I have been tangled many times, always in some small details on the wrong cause of the program run errors and began to suspect the correctness of the method, and always confused the number of judgment and the difference between the number of the prime.

Import Java.util.Scanner;

public class MyTest3 {

public static void Main (string[] args) {
/*
* Call the methods we have defined to determine the number of primes to be calculated,
Gets the input of an integer number (the hint is: how many primes to get),
And then from small to large output all eligible prime numbers
*/
int count =;

Showsushu (Getnum ("Please enter an integer:"));


Define a method that receives an integer, determines whether it is a prime number, and returns the judging result
/*
System.out.println ("Please enter an integer:");
int num;
Scanner sc = new Scanner (system.in);
num = Sc.nextint ();

Boolean BL = Sushu (num);

if (BL) {
System.out.println (num+ "is a prime number");
}else {
System.out.println (num+ "not Prime");
}
*/

}

public static int Getnum (String Tishi) {
System.out.println (Tishi);
int count;
Scanner sc = new Scanner (system.in);
Count = Sc.nextint ();
return count;
}

public static void Showsushu (int count) {
if (count>0) {
System.out.println ("The primes we Get are:");
for (int i=2; count>=1; i++) {
if (Sushu (i)) {
count--;
if (count%10==0)
System.out.println ("");
System.out.print (i+ "");
}
}
}else {
SYSTEM.OUT.PRINTLN ("Input value must be greater than 0");
}
}

/**
* Calculate whether it is a prime number
* @param num passed in integer
* @return Returns a Boolean value, True, is a prime number, otherwise, not a prime
*/
public static Boolean sushu (int num) {
if (num<2) {
return false;
} else{
for (int i=2; i<=num/2; i++) {
if (num%i==0) {
return false;
}
}
}
return true;
}

}

--------------------------------------------------------------------------------------------------------------- ------------------------------------

Through this week's study, I held myself not only to strengthen the study of textbooks, but also to find their own learning methods, in the teacher's classroom work, I am very difficult to get along with the solution, encountered a problem without a clear idea, there is no clear understanding of the substitution, do not know how to start this topic. I think this is the focus I need to solve at the moment, there is no good method of thinking, in solving the problem of the program more than the idea of students to spend a lot of time, but the program is not more than others, feel wasted a lot of time. In the process of writing a program I generally use their own commonly used things do not want to use other methods, do not want to try is not used to other methods are not familiar, resulting in the need to use other methods to solve the problem when overwhelmed, a face of the force!!! So also need to strengthen the knowledge of the consolidation, the basic knowledge is important, although some commonly used are not commonly used, but it is not commonly used will be ignored by us leading us to solve some problems is a little out of the question. There is this weekend, the bedroom installed broadband, but the connection route when I actually a face confused force on this feeling is not silly, my days. It's over this week and it's going to work next week.

Problems encountered in learning Java basics

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.