This Java programming tutorial will be read how to get prime number. First of all we will define a class "Prime Number". Java I/O package has a input stream and a output stream in which input stream is used for reading the stream and memory allocating and the output stream used for writing bytes. As in this program we are going to insert certain instruction by creating buffer reader class. Here we have to create a buffer for the string class that can be used to instantiate a changeable object for storing and processing a string of character. Now use the ParseInt method for converting the parses the string argument and define 'num' as an integer.
Now applying in this program two for loop conditions first condition as integer i=1, i< num and i++ is increment and second condition with as integer j=2, j<i, or j++ increment operator. So output result will be like int n=i%j.
Here is the code of the Program
import java.io.*;
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Prime Number in Java View All Comments
Post your Comment