Home Tutorialhelp Comment Wrong in the if statement block

 
 

Comment

Phumlani Mkhize
Wrong in the if statement block,
March 1, 2010 at 5:37 AM

The code below uses a wrong operator to compare two integer values. It is uses an assignment operator which is =
instead of == or equals keyword

Below is the link from where the error came from.
http://www.roseindia.net/interviewquestions/corejava.shtml

public class test {
public static void main(String [] args) {
int x = 3;
int y = 1;
if (x = y)
System.out.println("Not equal");
else
System.out.println("Equal");
}
}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Interview Questions

Statement block
Statement block  What is the purpose of a statement block 

Programming Tutorials

Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
not statically import a database driver class ? Ans : The standard import statement... with a single SQL statement does not make sense from a database management point of view. INSERT statement creates records and these records should be distinct from each 

Java Beginners

corejava - Java Beginners
block, function or class can be declared as a synchronized one.  Hello 

Java Beginners

try and finally block
try and finally block  hello, If I write System.exit (0); at the end of the try block, will the finally block still execute?   hii, if we use System.exit (0); statement any where in our java program 

Java Beginners

CoreJava
 

Java Interview Questions

corejava
 

Java Beginners

corejava
 

Java Tips and Examples

if Statement - Overview
-braced single statement or a braced block. Braces have been used in most...Java Notesif Statement - Overview Purpose The purpose of the if statement... with if. [The other 1% of the decisions use the switch/case statement 

Java Interview Questions

Maximum number of catches for a try block
Maximum number of catches for a try block  How many catch statements are allowed for a try statement?   Hello Friend, You can use any number of catch statement for a try statement. Thanks 

JSP Servlet Questions

what is wrong with my JSP codes for updating a form?
what is wrong with my JSP codes for updating a form?  Hi experts.... Hope someone can advise me where I had gone wrong. Tks. I've set up my...; Statement stmt = null; try 

Java Beginners

What's wrong with my form? - Java Beginners
What's wrong with my form?  Dear expert, I'm having trouble with my enquiry form. Hope you can tell me where my mistake lies. Thanks...; Statement stmt = null; String strName = ""; String 

Java Beginners

What's wrong with my pagination code in JSP?
What's wrong with my pagination code in JSP?  Dear experts, I've tried the following codes which I have copied from Java Ranch forum and deleted... = null; ResultSet rs = null; Statement stmt = null 

Tools For Java Technology

The Switch statement
. Then there is a code block following the switch statement that comprises... a statement following a switch statement use break statement within the code block... to note here is that the body of a switch statement is known as a switch block 

Java Beginners

CoreJava Project
CoreJava Project  Hi Sir, I need a simple project(using core Java, Swings, JDBC) on core Java... If you have please send to my account 

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...' c = Color.blue; But this is WRONG, because 'else' always goes 

Mobile Applications Questions

wrong year
wrong year  hello I m using the following code: NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy"]; NSDate *date... wrong year..   I think u are using other calendar Check Settings 

Java Tips and Examples

if Statement - Overview
whether they are dealing with an un-braced single statement or a braced block... Java Notesif Statement - Overview Purpose The purpose of the if statement is to make decisions, and execute different parts of your program depending 

PHP Questions

Switch statement in PHP
expression. It does execute the statement until the end of the block till it finds...Switch statement in PHP  HII, Explain about switch statement in PHP?   hello, Switch statement is executed line by line. PHP executes 

Java Beginners

finally block
finally block  hii, If I am writing return at the end of the try block and some code in finally block, then the finally block will execute??   hello, certainly finally block will execute 

JavaScript Tutorial

JavaScript Exception Handling
JavaScript Exception Handling: Try...catch block help to handle the exception handling, try..catch block works together.  You use the catch statement... of the code occurs in the block of code defined by the try statement 

Programming Tutorials

Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
 

Programming Tutorials

Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
 

Programming Tutorials

Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
 

Java Beginners

Continue and break statement
, which contain a block of statement. We are printing right angle triangle..., which contain a block of statement. We are printing right angle triangle... statement in java program?   The continue statement restart the current 

Java-Tutorials

If statement in java 7
if statement inside the if block. Syntax : if(condition1) { if(condition2... that means if you want to write if statement inside the else block then you can...If statement in java 7 This tutorial describes the if statement in java 7 

Java Beginners

Java Function for block inside a block
Java Function for block inside a block  Write a function in Java that attempts to place a set of squares of varying widths into another, larger square. If there is no possible layout, return undefined. Otherwise, return 

Java Beginners

Java Function for block inside a block
Java Function for block inside a block  Write a function in Java that attempts to place a set of squares of varying widths into another, larger square. If there is no possible layout, return undefined. Otherwise, return 

Java-Tutorials

Switch Statement in java 7
Switch Statement in java 7 This tutorial describes the if statement in java 7. This is one kind of decision making statement. Switch Statements : The switch statement is used when you want to test many statements based on some 

JDBC Questions

prepared statement in for loop - JDBC
prepared statement in for loop  Hi all, I am reding data from a jsp page and inserting into a table. For this i am using prepared statement... doing anything wrong? Here is my code: strB2B = (String)poForm.get("POB2B 

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 

JSP-Tutorials

JSP IF Statement
JSP IF Statement In this section we will read about how the If statement is used in the JSP programming. In JSP, If statement can be used as it is used in the core Java programming. Additionally, in JSP the conditional if statement 

Java Beginners

corejava - Java Beginners
corejava pass by value semantics  Example of pass by value semantics in Core Java.  Hi friend,Java passes parameters to methods using pass by value semantics. That is, a copy of the value of each of the specified 

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 Example
. Now you are aware of if block, now we are going to use if statement using...JSP If statement Example In this section with the help of example you will learn about the "If" statement in JSP. Control statement is used 

Java Beginners

What is wrong with this line
What is wrong with this line  What is wrong with this line JOptionPane.showMessageDialog(null? for Using Lewandowski's Savings pgrm!"); from if (input.equals("exit") || input.equals("Exit")) { JOptionPane.showMessageDialog 

PHP Tutorial

IF-Else Conditional Statement
, it jumps to the statement next to if block. The syntax is given below...! if...else statement This statement executes 'if block' if condition.......else statement First, It checks condition in 'if' block. If it is true 

Java Beginners

what is wrong with this program
what is wrong with this program  import java.io.*; class Distance { int feet,inch; void read() { System.out.println("Enter distance in feet and inches "); feet=Integer.parseInt(ob.readLine()); inch 

Java Beginners

What is wrong with my servlet?
What is wrong with my servlet?  I'd like to know which part of the code is wrong. My code is: print("code sample"); import java.util.*; import java.io.IOException; import java.io.PrintWriter; import 

JDBC

JDBC Prepared Statement Insert
JDBC Prepared Statement Insert   ... Statement Insert. In this Tutorial  the code describe the include a class... in backend. Loading a driver inside the try block by calling a class.forName 

Java Beginners

what is wrong in this program
what is wrong in this program  import java.io.*; class Distance { int feet; int inch; void read(int feet, int inch) { System.out.println("Enter distance in feet and inches "); feet=Integer.parseInt(ob.readLine 

Java Beginners

what is wrong in this program......
what is wrong in this program......  program to implement given inheritance import java.io.*; class Student { int rno; String name; DataInputStream ob = new DataInputStream(System.in); void getRoll 

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 Beginners

corejava - Java Beginners
 

Java Beginners

corejava - Java Beginners
 

Java Beginners

corejava - Java Beginners
 

Java Beginners

corejava - Java Beginners
 

Java Beginners

corejava - Java Beginners
 

Java Interview Questions

Corejava - Java Interview Questions
 

Java Beginners

corejava - Java Beginners
 

Java Interview Questions

corejava - Java Interview Questions
 

Java Interview Questions

corejava - Java Interview Questions
 

Java Interview Questions

corejava - Java Interview Questions
 

Java Interview Questions

corejava - Java Interview Questions
 

Java Interview Questions

corejava - Java Interview Questions
 

Java Interview Questions

corejava - Java Interview Questions
 

Java Beginners

CoreJava - Java Beginners
 

Java Beginners

Is catch(){} block synchronized?
Is catch(){} block synchronized?  The code in catch(){} block behaves synchronized. In one block, if I do {write to file1; write to file2}, and in another {write to file2; write to file1}, they deadlock. Is this implicit sync 

Java Beginners

URL Block - Java Beginners
URL Block  Hello sir, How to block one website using java.for example if we want block "www.orkut.com" site,how to block this site using java... to block a URL like this?please help me.. Thanking you 

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 

JDBC

Jdbc Insert Statement
JDBC Insert Statement       Add a row to a existing table using insert statement in JDBC. The tutorial illustrates an example from JDBC Insert Statement. In this program 

JDBC

Executing Prepared Statement
; } Executing Prepared Statement Prepared Statement represents the pre... is no-parameter prepared statement example. Example- At first create table named student...) { // TODO Auto-generated catch block e.printStackTrace 

Java Beginners

doubt on synchronized block in java
doubt on synchronized block in java  Hi ! some people are feeling... suggestinons.Today i am going to ask on synchronized block. the general form of synchronized block is class table { ....... void printTable(int n 

JDBC

JDBC Prepared Statement Update
JDBC Prepared Statement Update       The Update  Statement... Statement Update is used to update the SQL statement, using where clause 

JSP Tutorials

Use Compound Statement in JSP Code
Use Compound Statement in JSP Code       A compound statement is collection of statements enclosed with in braces. In general, statement works without braces 

JDBC Questions

check condition in if-else block
 

JDBC Questions

closing connections in finally block
 

JDBC

JDBC Prepared Statement Addbatch
JDBC Prepared Statement Addbatch       The code illustrate an example from JDBC Prepared statement... a connection between url and database.4) prepare Statement ( ) -This method is used 

JDBC

JDBC Execute Statement
JDBC Execute Statement       JDBC Execute Statement is used to execute SQL Statement, The Execute Statement accept SQL object as parameter and return you the result set from 

Java-Tutorials

For Loop Statement in java 7
For Loop Statement in java 7 In this section, we will discuss about for loop in java 7. This is one type of  loop statement. For Loop Statements : For loop is one way of looping to iterate block of code under certain condition 

General

Finally in java
to return to the caller from inside try/catch block through a return statement...Finally in java In this section we will discuss about finally block in java. Finally block always execute when try block exits. Finally is a block of code 

Java Tips and Examples

Summary - Control Flow
Java: Summary - Control Flow Each control statement is one logical statement, which often encloses a block of statements in curly braces {}. The if else statement can be used in following ways: a) if ..else b) if .. elseif 

Struts Questions

error cannot access class com.opensymphony.xwork2.ActionContext, wrong version
error cannot access class com.opensymphony.xwork2.ActionContext, wrong version  Error(1,32): cannot access class com.opensymphony.xwork2.ActionContext; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0 

JSP Tutorials

How to use switch statement in jsp code
of the block Main reason is to use break statement is find proper output... How to use switch statement in jsp code       switch is a type of control statement used 

General

The finally Keyword
; The finally is a Java keyword that is used to define a block that is always executed in a try−catch−finally statement. In java.... A finally block typically contains cleanup code that recovers from partial 

SQL Question

Sql aggregate function with left join wrong output
Sql aggregate function with left join wrong output    I have three tables Stock,InwardEntry,IssueToProd. Part_no in stock is a primary key... I ma getting wrong sum values of i.InvoiceQuantity,p.IssueQuantity column 

SQL Question

Sql aggregate function with left join wrong output
Sql aggregate function with left join wrong output    I have three tables Stock,InwardEntry,IssueToProd. Part_no in stock is a primary key... I ma getting wrong sum values of i.InvoiceQuantity,p.IssueQuantity column 

SQL Question

Sql aggregate function with left join wrong output
Sql aggregate function with left join wrong output    I have three tables Stock,InwardEntry,IssueToProd. Part_no in stock is a primary key... I ma getting wrong sum values of i.InvoiceQuantity,p.IssueQuantity column 

JSP Tutorials

Use multiple catch statement in single jsp
exceptions). When exception occurs while executing any statement within try block... Use multiple catch statement in single jsp  ... catch statements. The code bound by the try block need not always throw a single 

Java Beginners

Not sure whats wrong with my code HELP PLEASE?!?!
Not sure whats wrong with my code HELP PLEASE?!?!  I cant figure out what I am doing wrong in my code can anyone help me out??? Grades function computeGrade( ) { var hw, lab, midt, fin, avg; hw = parseFloat 

RMI Questions

block IP of LAN machines from server - RMI
block IP of LAN machines from server  i want to block the IP... server. IP block means,I want to restrict them to access the internet. so, how is it possible to block IP of LAN machines from server 

Java Beginners

according to me its ok but is calculating wrong values in
according to me its ok but is calculating wrong values in   program to calculate roman numbers .....i.e roman number calculator import java.util.*; import java.io.*; class romancalci { public static void main(String 

General

Nested Try-Catch Blocks
that, a try statement can be inside the block of another try. If an inner try statement does not have a matching catch statement for a particular exception, the control  is transferred to  the next try statement?s catch handlers 

PHP Tutorial

Do..While Loops
3.10.2. Do…While Loops The do...while statement always execute the block of code once, then check the condition, and repeat the loop until the condition is true. Syntax do { code to be executed; } while (condition); e.g. 

Java Tips and Examples

Summary - Statements
Java: Summary - Statements Each control statements is one logical statement, which often encloses a block of statements in curly braces {}. The examples assume the block contains more than one statement. The effect of the switch 

Java Beginners

a competitive study on cryptography techniques over block cipher
a competitive study on cryptography techniques over block cipher  i need "a competitive study on cryptography techniques over block cipher" project source code... plz reply to my post... for more information about this project 

JSP Servlet Questions

Block edit menu option - JSP-Servlet
Block edit menu option  I am doing a jsp project. I have to control number of characters in a text area upto a limit. How can i block pasting through edit menu and pasting through short cut key [ctrl+v 

PHP Questions

if statement in php
if statement in php  Correct way of writing if statement in PHP 

Java Beginners

java if statement
java if statement  If statement in Java 

Hibernate Questions

executing mysql plsql block using hibernate
executing mysql plsql block using hibernate  I got one requirement like this, I have to execute following query by using hibernate DECLARE @i_STARTDATETIME DATETIME DECLARE @i_ENDDATETIME DATETIME DECLARE @o_ERRORCODE INT 

Java Beginners

prepare statement
prepare statement  sir i want example of prepare statement 

General

The break Keyword
a for, while, or do loop or to mark the end of a case block in a switch statement... within a block of code that immediately comes to the currently enclosing block... an innermost enclosing while, for, do or switch statement. The break statement 

General

Java Control Statement
then it will execute the rest of the code. You can put a single statement or block... Code Looping statement : When we need to execute a block of code several...Java Control Statement Control flow statement is a statement that is used 

General

The else Keyword
statement that starts the 'false' statement block. else  is a java keyword...; The else is the one more keyword of Java. It is used to specify a statement or block of statements that are executed when the condition for testing specified 

Java Beginners

difference between prepared statement and statement
difference between prepared statement and statement  i mean in prepared statement we write insert command as INSERT INTO tablename VALUES(?,?) but in normal statement we write insert into tablename(jtextfiled1.gettext 

Java Beginners

Print a statement
Print a statement  hello what would we output for this statement System.out.println ("5"+"A" + 3);   hello output will be 5A3 

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 

Programming Tutorials

Use if statement with LOOP statement
Use if statement with LOOP statement   ... with Example The Tutorial illustrate a example from if statement with LOOP statement. In this example we create a procedure display that accept 

Java Beginners

Switch Statement
switches to statement by testing the value. import java.io.BufferedReader; import... switch case statement. The program displays the name of the days according to user 

Java Beginners

cONDITIONAL STATEMENT
cONDITIONAL STATEMENT    Write a program that computes and assesses the tuition fee of the students in one trimester, based on the given mode of payment below: Plan (Key) Discount (-) or Interest (+) Cash (1) 10% Discount Two 

Java-Tutorials

Exception Handling : Multiple Catch
statement. It the first statement is correct, then  the first catch block... of declaring multiple catch  with the try block. Multiple Catch : A try statement can have multiple catch blocks. Through multiple catch 

Advertisements Advertisements
 

 

 

DMCA.com