Correct errors

Correct errors

Identify and correct the errors in the following program:
public java Method
{
public static method1(int n, m)
{
n += m;
xMethod(3. 4);
}
public static int xMethod(int n)
{
if (n > 0) return 1;
else if (n == 0) return 0;
else if (n < 0) return -1;
}
}
View Answers

March 23, 2010 at 10:42 AM

Hi Friend,

Try the following code:

public class Example{
public static void main(String[]args){
method1(1,-2);
}

public static void method1(int n, int m){
n += m;
int result=Example.xMethod(n);
System.out.println(result);
}
public static int xMethod(int n){
if (n > 0) return 1;
else if (n == 0) return 0;
else if (n < 0) return -1;
return 0;
}
}

Thanks









Related Tutorials/Questions & Answers:
Correct errors - Java Beginners
Correct errors  Identify and correct the errors in the following program: public java Method { public static method1(int n, m) { n += m; xMethod(3. 4); } public static int xMethod(int n) { if (n > 0) return 1
errors
that what the errors in above code
Advertisements
check for errors
check for errors  How can I check for errors
What is the errors?
What is the errors?  ) while ( c <= 5 ) { product *= c; ++c;   if ( gender == 1 ) cout << "Woman" << endl; else; cout << "Man" << endl;   Post the whole code
errors
compilation errors
() { } } giving errors: 1) WelcomeServlet.java:37: ')' expected
types of errors in php
types of errors in php  What are the different types of errors in php
ModuleNotFoundError: No module named 'errors'
ModuleNotFoundError: No module named 'errors'  Hi, My Python... 'errors' How to remove the ModuleNotFoundError: No module named 'errors'... to install padas library. You can install errors python with following command
Compiler errors in java
Compiler errors in java  Hi, I used GenerateRDF java file. Am getting errors when i run this code. I used command prompt only. getting errors as no package exist. i followed your instructions properly. Please help me out
Free Java Is it correct?
Free Java Is it correct?  Hi, Is Java free? If yes then where I can download? Thanks   Hi, You can download it from http://www.oracle.com/technetwork/java/javase/downloads/index.html Thanks
what is the correct format of charAt() function?
what is the correct format of charAt() function?   class prog... program the following errors are coming: p3.java:8:cannot find symbol symbol...)=='a'){ But the syntax of the charat()function is correct in the code.  Hi Friend
selectoptions errors in java script
selectoptions errors in java script  hi, in my web page when I select the color of the image it displays that particular color but when i again opt the select option it displays errors message. How do I rectify this problem
Servlets errors in same page.
Servlets errors in same page.  How do I display errors list in the same page where a form field exists using servlets...........i.e. without using JSP? Please explain with a simple username password program
The errors tag
In this section, you will learn about the errors tag of the Spring form tag library
jsp errors - JSP-Servlet
jsp errors  Hi I got errors when running a jsp file I am giving the file. this is from rose india. I set the class path for 3 jar files i.e.... Now i am getting less errors compared to previous. But I am getting 2 errors
Can you correct this codes?
Can you correct this codes?  Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 4 at searchcon.(searchcon.java:39) at search.initComponents(search.java:41) at search.(search.java:7) at payroll
please correct this program
please correct this program  import java.util.Scanner; public class Nam { public static void main (String arg[]) { String[] name={"Aki","Karthi","Tk","Suba","Malu","Buvi","Janu","Sara","Sandy","Abi","Ani","Amu
correct the sql error
correct the sql error  i am getting a SQL Error while retriving data from access to jframe called "datatype mismatch in criteria expression" plez do help me and studentId's datatye is number...... private void
ModuleNotFoundError: No module named 'correct_pycountry'
ModuleNotFoundError: No module named 'correct_pycountry'  Hi, My... named 'correct_pycountry' How to remove the ModuleNotFoundError: No module named 'correct_pycountry' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'correct_pycountry'
ModuleNotFoundError: No module named 'correct_pycountry'  Hi, My... named 'correct_pycountry' How to remove the ModuleNotFoundError: No module named 'correct_pycountry' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'correct-horse'
ModuleNotFoundError: No module named 'correct-horse'  Hi, My... 'correct-horse' How to remove the ModuleNotFoundError: No module named 'correct-horse' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'reynir-correct'
ModuleNotFoundError: No module named 'reynir-correct'  Hi, My... named 'reynir-correct' How to remove the ModuleNotFoundError: No module named 'reynir-correct' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'correct-horse'
ModuleNotFoundError: No module named 'correct-horse'  Hi, My... 'correct-horse' How to remove the ModuleNotFoundError: No module named 'correct-horse' error? Thanks   Hi, In your python
WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?
WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?  WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP
Java Program Errors
Java Program Errors  These are the 2 errors which I am getting when executing the java source code extracted from executable jar file The project was not built since its build path is incomplete. Cannot find the class file
ModuleNotFoundError: No module named 'masonite-errors'
ModuleNotFoundError: No module named 'masonite-errors'  Hi, My... named 'masonite-errors' How to remove the ModuleNotFoundError: No module named 'masonite-errors' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pretty-errors'
ModuleNotFoundError: No module named 'pretty-errors'  Hi, My... 'pretty-errors' How to remove the ModuleNotFoundError: No module named 'pretty-errors' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-errors'
ModuleNotFoundError: No module named 'django-errors'  Hi, My... 'django-errors' How to remove the ModuleNotFoundError: No module named 'django-errors' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'edeposit.amqp_errors'
ModuleNotFoundError: No module named 'edeposit.amqp_errors'  Hi...: No module named 'edeposit.amqp_errors' How to remove the ModuleNotFoundError: No module named 'edeposit.amqp_errors' error? Thanks   Hi
ModuleNotFoundError: No module named 'haiku-errors'
ModuleNotFoundError: No module named 'haiku-errors'  Hi, My Python... 'haiku-errors' How to remove the ModuleNotFoundError: No module named 'haiku-errors' error? Thanks   Hi, In your python
STRUTS2.0 Validation Errors
the previous field errors persist in the page. For eg:if i am not entering both
Java errors when attempting the following.
Java errors when attempting the following.  Give the java errors in attempting the following : 1) performing division operation on string value. 2) redefining base class final method in derived class. 3) defining a method
date_get_last_errors
date_get_last_errors date_get_last_errors alias DateTime::getLastErrors function returns the warnings and errors while parsing a date/time string... about warnings and errors. Example: <?php $date = date_create('asdfasdf
Need urgent help with C++ errors!
Need urgent help with C++ errors!  hi, i'm new to C++ programming. this is my code... i'm using Turbo C++. It's showing so many errors!.. I...() { cout<<"Can somebody fix this?"; } the errors are listed as follows
what error in this program plese correct it
what error in this program plese correct it  import java.io.*; class y { public static void main (String args[]) { Data inputStream dis = new Data inputstream(System.in); float l,b,a; Systyem.out.println("enter the lengh"); l
Is this correct???what are the unnessasary codings here??
Is this correct???what are the unnessasary codings here??  import java.util.Scanner; public class Length { public int meters; public int centiMeters; public double yards; public double feet; public double inches
remopving errors incore java programming
remopving errors incore java programming  sir error in program:-file does not contain class runnable program:- class MyRunnable implements Runnable{ public void run(){ System.out.println("Run"); } public
remopving errors incore java programming
remopving errors incore java programming  sir error in program:-file does not contain class runnable program:- class MyRunnable implements Runnable{ public void run(){ System.out.println("Run"); } public
remopving errors incore java programming
remopving errors incore java programming  sir error in program:-file does not contain class runnable program:- class MyRunnable implements Runnable{ public void run(){ System.out.println("Run"); } public
need to fix errors please help
need to fix errors please help  it does have 2 errors what should i fix? import java.io.*; class InputName static InputStreamReader reader = new InputStreamReader(system.in); static BufferedReader input = new BufferedReader
Runtime Errors
Runtime Errors          Errors are arised when there is any logic problem with the logic of the program.  In this program we are trying
ModuleNotFoundError: No module named 'django-client-errors'
ModuleNotFoundError: No module named 'django-client-errors'  Hi...: No module named 'django-client-errors' How to remove the ModuleNotFoundError: No module named 'django-client-errors' error? Thanks   Hi
ModuleNotFoundError: No module named 'drf-friendly-errors'
ModuleNotFoundError: No module named 'drf-friendly-errors'  Hi, My... named 'drf-friendly-errors' How to remove the ModuleNotFoundError: No module named 'drf-friendly-errors' error? Thanks   Hi
ModuleNotFoundError: No module named 'cf-pretty-form-errors'
ModuleNotFoundError: No module named 'cf-pretty-form-errors'  Hi...: No module named 'cf-pretty-form-errors' How to remove the ModuleNotFoundError: No module named 'cf-pretty-form-errors' error? Thanks   Hi
ModuleNotFoundError: No module named 'datasette-show-errors'
ModuleNotFoundError: No module named 'datasette-show-errors'  Hi...: No module named 'datasette-show-errors' How to remove the ModuleNotFoundError: No module named 'datasette-show-errors' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-client-errors'
ModuleNotFoundError: No module named 'django-client-errors'  Hi...: No module named 'django-client-errors' How to remove the ModuleNotFoundError: No module named 'django-client-errors' error? Thanks   Hi
ModuleNotFoundError: No module named 'drf-friendly-errors'
ModuleNotFoundError: No module named 'drf-friendly-errors'  Hi, My... named 'drf-friendly-errors' How to remove the ModuleNotFoundError: No module named 'drf-friendly-errors' error? Thanks   Hi
ModuleNotFoundError: No module named 'drf-friendly-errors-mod'
ModuleNotFoundError: No module named 'drf-friendly-errors-mod'  Hi...: No module named 'drf-friendly-errors-mod' How to remove the ModuleNotFoundError: No module named 'drf-friendly-errors-mod' error? Thanks   
Getting 404 errors - Java Beginners
password access I received a 404 errors and I identified that the servlet
Help please, some strange errors
this errors so i have posted the whole program here. Here i tried to make the monopoly... is causing that run-time errors? Any kind of help will be helpful to me. and let

Ads