Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Java Beginners Learn from Naruto
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Naruto7" data-source="post: 15975204" data-attributes="member: 384482"><p><span style="font-size: 12px">I thought of Sharing my knowledge which i got from IJTS (the BEST COLLEGE FOR JAVA) to beginners. not for experts.So if you have any questions regarding basic stuff post here so we can advance step by step.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">First ill post a program where it finds whether the number is a prime or not and tells a num which divides it.Just go through it n try to learn whats going through.It will help you to understand basic concepts. </span></p><p style="text-align: left"></p> <p style="text-align: left"><span style="font-size: 12px"><strong>import java.util.*;</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong></strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong>public class PrimeNum{</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong>public static void main(String args[]){</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> Scanner x=new Scanner(System.in);</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> System.out.println("Enter the number : ");</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> int y=x.nextInt();</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> int i;</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> for( i=2;i<y;i++){</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> int z=y%i;</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> if(z==0){</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> System.out.println("Number is not prime");</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> System.out.println(y+" Divide by "+i);</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> i=y; </strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> }</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> </strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> }if(i==y || y==1) System.out.println("Number is prime"); </strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong> }</strong></span></p> <p style="text-align: left"><span style="font-size: 12px"><strong>}</strong></span></p> <p style="text-align: left"></p></blockquote><p></p>
[QUOTE="Naruto7, post: 15975204, member: 384482"] [SIZE=3]I thought of Sharing my knowledge which i got from IJTS (the BEST COLLEGE FOR JAVA) to beginners. not for experts.So if you have any questions regarding basic stuff post here so we can advance step by step. First ill post a program where it finds whether the number is a prime or not and tells a num which divides it.Just go through it n try to learn whats going through.It will help you to understand basic concepts. [/SIZE] [LEFT] [SIZE=3][B]import java.util.*; public class PrimeNum{ public static void main(String args[]){ Scanner x=new Scanner(System.in); System.out.println("Enter the number : "); int y=x.nextInt(); int i; for( i=2;i<y;i++){ int z=y%i; if(z==0){ System.out.println("Number is not prime"); System.out.println(y+" Divide by "+i); i=y; } }if(i==y || y==1) System.out.println("Number is prime"); } }[/B][/SIZE] [/LEFT] [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom