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

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  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

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 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 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 Tips and Examples

'if' Statement - if inside if
Java Notes'if' Statement - if inside if if inside if You can put an if statement inside another if statement. Example -- series... the condition in an if statement, Java thinks it's finished with the body 

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 Tips and Examples

if Statement - Overview
Java Notesif Statement - Overview Purpose The purpose of the if statement is to make decisions, and execute different parts of your program depending... with if. [The other 1% of the decisions use the switch/case statement 

Java Tips and Examples

if Statement - Overview
Java Notesif Statement - Overview Purpose The purpose of the if statement... is a statement? A statement is a part of a Java program. We have already... directly after the condition in an if statement, Java thinks it's finished 

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 Tips and Examples

'if' Statement - Braces
Java Notes'if' Statement - Braces Braces { } not required for one statement If the true or false part of and if statement has only one... was expected. What is a statement? A statement is a part of a Java 

Java Tips and Examples

'while' Statement
Java Notes'while' Statement Purpose - to repeat statements The purpose of the while statement is to repeat a group of Java statements many times. It's written just like an if statement, except that it uses 

General

Java Import Statement Cleanup - Java Tutorials
Java Import Statement Cleanup 2002-06-18 The Java Specialists' Newsletter [Issue 051] - Java Import Statement Cleanup Author: Dr. Cay S. Horstmann... to receive training in Design Patterns. Java Import Statement Cleanup 

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 

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 

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 

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 

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

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

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 

DMCA.com