Home Discussion Discuss: Java - Break statement in java

  • Ironic...Wolf_22 August 18, 2011 at 6:05 PM

    Why on Earth would you use 2 FOR loops with modulus conditioning of single-character variables to explain BREAK statements!? (If someone comes to this website seeking an explanation about BREAK, then is it fair to assume that the person might have problems understanding your demo?)

  • code understandingfarhat bouchnak April 30, 2012 at 9:26 PM

    hi is it right to use with if only break? please help me and how?

  • output not correctanoop June 17, 2012 at 11:50 PM

    public class Break{ public static void main(String[] args){ int i,j; System.out.println("Prime numbers between 1 to 50 : "); for (i = 1;i < 50;i++ ){ for (j = 2;j < i;j++ ){ if(i % j == 0) { break; } } if(i-1 == j) //THE CORRECTION { System.out.print(" " + i); } } } } how to get the 2 in output?

  • No CorrectionRubbal Bhusri August 25, 2013 at 10:02 AM

    The code given above produces fair result. I've checked it and there isn't any need of correction in it, because it print all the prime numbers starting from 2 and ends at 47, which is, it suppose to display. So, all works good in this code.

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
Java Beginners

java if statement
java if statement  If statement in Java 

Java Beginners

switch statement
switch statement   i want to write a java program that computes Fibonacci,factorial,string reversal and ackerman using switch case to run as a single program 

Java Beginners

if else statement in java
if else statement in java  if else statement in java explain with example 

Java Beginners

Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java 

Java Beginners

JAVA statement - Java Beginners
JAVA statement  The import statement is always the first noncomment statement in a Java program file.Is it true?  Hi Friend, No,it is not true.If your class belongs to a package, the package statement should 

Java Beginners

if else statement in java
if else statement in java  explain about simple if else statement and complex if else statement in java with an example 

Java Interview Questions

Java callable statement
Java callable statement  What is callable statement? Tell me the way to get the callable statement 

Java Beginners

conditional statement in java
conditional statement in java  Write a conditional statement in Java   Logical and comparison statements in OOPs are also know as conditional statements. You can learn "How to write conditional statement in Java " from 

Java Interview Questions

Java switch statement
Java switch statement  What restrictions are placed on the values of each case of a switch statement 

Java Beginners

GOTO Statement in java
GOTO Statement in java  I have tried many time to use java goto statement but it never works i search from youtube google but e the example on net are also give compile error. if possible please give me some code with example 

Java Beginners

ELSE STATEMENT!! - Java Beginners
ELSE STATEMENT!!  Hi! I just want to know why doesn't my else statement works? Else statement is there in the code below which is: else JOptionPane.showMessageDialog(null, n+ " is not in the array!");//doesn't work 

Java Beginners

Java IF statement problem
Java IF statement problem  Dear Sir/Madam i am using the following code. expected to not have any output but it still showing "welcome".. please help me why it showing "welcome". class c1 { int a=5; while(a>1 

Java Beginners

What is the difference between an if statement and a switch statement?
What is the difference between an if statement and a switch statement?   Hi, What is the difference between an if statement and a switch statement? Thanks,   Hi, The if statement gives options to select one option 

Java-Tutorials

If statement in java 7
If statement in java 7 This tutorial describes the if statement in java 7. This is one kind of decision making statement. There are various way to use if statement with else - If Statement :  If statement contains one boolean 

Java Beginners

While loop Statement.
While loop Statement.   How to Print Table In java using While Loop 

Java-Tutorials

Continue Statement in java 7
Continue Statement in java 7 In this tutorial we will discuss about continue statement in java 7. Continue Statement : Sometimes you need to skip block... statement in loops. In java 7, Continue statement stops the current iteration 

Java Interview Questions

for statement
for statement  for(int i=0;i<5;i++); { system.out.println("The value of i is :"+i); } if i end for statement what will be the output   got the answer.. it displays only the last iteration that is "The value of i 

JSP-Tutorials

JSP IF Statement
in the core Java programming. Additionally, in JSP the conditional if statement... and/or as the IF-ELSE statement and/or IF-ELSE ladder statement. In Java we can use...JSP IF Statement In this section we will read about how the If statement 

General

Continue Statement
about Continue Statement click on the link http:/www.roseindia.net/java/beginners... Continue Statement       The continue statement occurs only inside the iterator statements like while 

JDBC

JDBC Prepared Statement Example
JDBC Prepared Statement Example       Prepared Statement is different from Statement object, When it is created ,it is represented as SQL statement. The advantage 

JDBC

JDBC Prepared Statement Insert
JDBC Prepared Statement Insert   ... Statement Insert. In this Tutorial  the code describe the include a class... that enables you to communicate between front end application in java and database 

Java Beginners

Writing a loop statement using Netbean
Writing a loop statement using Netbean  Write a loop program using NetBeans.   Java Loops class Loops{ public static void main(String[] args){ int sum=0; for(int i=1;i<=10;i 

Java Beginners

count statement that saves results on a variable in a java bean
count statement that saves results on a variable in a java bean  ...; Statement statement = null; String SQLStr ; String retString...:3306/dev","root","anime"); statement = conn.createStatement 

Java Beginners

count statement that saves results on a variable in a java bean
count statement that saves results on a variable in a java bean  ...; Statement statement = null; String SQLStr ; String retString...:3306/dev","root","pro"); statement = conn.createStatement 

JDBC Questions

UNICODE or SQL statement issue - JDBC
UNICODE or SQL statement issue  Hi again............ I have got something new that........... i was using MS Access as the database with my JAVA Japplet.... In my applet i used JTextArea to display the output 

Java Beginners

Java Error In comapitable Type in statement - Java Beginners
Java Error In comapitable Type in statement  Here I want to Check...; //Statement st; faculty3() //constructor { j=new JFrame("faculty"); j1...; PreparedStatement st; //Statement st; faculty3(){ j=new JFrame("faculty 

Java Beginners

syntax error in SQL Insert Statement - Java Beginners
Access Driver] Syntax error in INSERT INTO statement. plz Help Me  Hi 

JDBC

JDBC Prepared statement Close
JDBC Prepared statement Close       The Prepared statement interface extends from statement. An statement specify a precompiled SQL Statement. This specify a same object 

General

Java error missing return statement
Java error missing return statement       Java error missing return statement are those error in Java that occurred when a programmer forget to write 

General

Implementing Continue Statement In Java
Implementing Continue Statement In Java       In this Session you will learn how to use continue statement. First all of define class "Continue" 

DMCA.com