to solve the error

to solve the error

View Answers

August 19, 2008 at 10:47 AM

Hi friend,


Your code having error :

You not have declare any main method
So java.lang.NoSuchMethodError: main error occur

and you add this main method in bubbleSort1 class.


public static void main(String a[]){
int i;
int array[] = {10,5,3,89,110,120,1,8,2,12};
System.out.println("Values Before the sort:\n");
for(i = 0; i < array.length; i++)
System.out.print( array[i]+" ");
System.out.println();
bubbleSort(array);
System.out.print("Values after the sort:\n");
for(i = 0; i <array.length; i++)
System.out.print(array[i]+" ");
System.out.println();
System.out.println("PAUSE");
}

Complete code for a class bubbleSort1

class bubbleSort1{

public static void main(String a[]){
int i;
int array[] = {10,5,3,89,110,120,1,8,2,12};
System.out.println("Values Before the sort:\n");
for(i = 0; i < array.length; i++)
System.out.print( array[i]+" ");
System.out.println();
bubbleSort(array);
System.out.print("Values after the sort:\n");
for(i = 0; i <array.length; i++)
System.out.print(array[i]+" ");
System.out.println();
System.out.println("PAUSE");
}

public static void bubbleSort(int[] x) {
int n = x.length;
for (int pass=1; pass < n; pass++) { // count how many times
// This next loop becomes shorter and shorter
for (int i=0; i < n-pass; i++) {
if (x[i] > x[i+1]) {
// exchange elements
int temp = x[i]; x[i] = x[i+1]; x[i+1] = temp;
}
}
}
}
}

For read more information :

http://www.roseindia.net/java/

Thanks









Related Tutorials/Questions & Answers:
to solve the error - Java Beginners
to solve the error  class bubbleSort1{ public static void..., Your code having error : You not have declare any main method So java.lang.NoSuchMethodError: main error occur and you add this main method
How to Solve the Syntax Error in java??
How to Solve the Syntax Error in java??  Syntax error in java? i have tried this program its showing error like this in Eclipse "Syntax error... of the program "objectname.i" What is the reason for this error??How to access the variable
Advertisements
please solve this error Warning: mail() [function.mail]:
please solve this error Warning: mail() [function.mail]:   please solve this error Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing
how to solve 'Stop Running This Script' Error ?
how to solve 'Stop Running This Script' Error ?  Hi.. When opened the page on IE browser(version : 8.0),it gives an java script error (i.e.Stop Running This Script). I have used jsp/servlet for this. Please help to resolved
How to solve ModuleNotFoundError: No module named 'paramiko' error
'paramiko' How to solve ModuleNotFoundError: No module named 'paramiko' error...How to solve ModuleNotFoundError: No module named 'paramiko' error  Hi, while importing following module: import paramiko I am getting the error
How to solve ModuleNotFoundError: No module named 'paramiko' error
'paramiko' How to solve ModuleNotFoundError: No module named 'paramiko' error...How to solve ModuleNotFoundError: No module named 'paramiko' error  Hi, while importing following module: import paramiko I am getting the error
OCI Connectivity For Oracle Plz Solve This Error
) { e.printStackTrace(); } } } ---> I found Error below how i can solve this error plz...OCI Connectivity For Oracle Plz Solve This Error  import java.io....({}); Package not found Error
OCI Connectivity For Oracle Plz Solve This Error
) { e.printStackTrace(); } } } ---> I found Error below how i can solve this error plz...OCI Connectivity For Oracle Plz Solve This Error  import java.io....({}); Package not found Error
how to solve this kind of error in Eclipse IDE?
how to solve this kind of error in Eclipse IDE?   i'm creating... are installed. but i'm getting exactly this error, any one out of this problem of error. thanks in advance. ![this is image of error, and i will try to start
how to solve error like'java.lang.NumberFormatException: For input string: "7600113411"' this
how to solve error like'java.lang.NumberFormatException: For input string: "7600113411"' this  java.lang.NumberFormatException: For input string: "7600113411"    java.lang.NumberFormatException: For input string
Solve it
Solve it  How to calculate the value which contains oparator and operand both using command line argument
solve this
solve this   Create a student class. The student object should have studentid, studentname, subject and marks as properties. Also generate the getter and setter methods. Create 5 objects of this class and populate values
error
(DriverManager.java:171) at excelDB.ExcelDB.main(Excel_DB.java:210) how to solve dis error
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version.ADS_TO_REPLACE_1 This type error also comes
Hibernate Error: Failed to create sessionFactory object.java.lang.NoClassDefFoundError
In this video you will learn why this error comes in the Hibernate project and how to solve the error? While working on a Hibernate/Java based after update... of Hibernate this error occurred. This is the runtime error and Hibernate application
solve this pbm
solve this pbm  its not working the code for databae access using servlets
ModuleNotFoundError: No module named 'solve'
ModuleNotFoundError: No module named 'solve'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'solve..., ModuleNotFoundError: No module named 'solve' error will be solved. Thanks
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
how to solve
how to solve   log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources). log4j:WARN Please initialize the log4j system properly
solve this pbm
solve this pbm  sir rows are also inserting i have checked in the database also the rows are not affected in the table . The first pbm wich i have sent to you is not yet solved.......... pls give me detail explaination how we
error
error  while iam compiling iam getting expected error
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
Solve
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error
"+it); } } this is my program i am getting an error saying cannot find symbol class stringADS
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner(System.in); int d,x,y; System.out.println("Enter the first number
solve this problem
solve this problem  I typed this program and compiled.The program is compiled but when i eneterd url in tomcat server. Its not giving error but only blank page is coming the text is not displaying and row is also inserted
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
ModuleNotFoundError: No module named 'flood-solve'
;flood-solve' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'flood-solve'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'magiceye_solve'
'magiceye_solve' error? Thanks   Hi, In your python... 'magiceye_solve' error will be solved. Thanks...ModuleNotFoundError: No module named 'magiceye_solve'  Hi, My
ModuleNotFoundError: No module named 'solve-instrument'
named 'solve-instrument' error? Thanks   Hi, In your...: No module named 'solve-instrument' error will be solved. Thanks...ModuleNotFoundError: No module named 'solve-instrument'  Hi, My
ModuleNotFoundError: No module named 'sudoku-solve'
;sudoku-solve' error? Thanks   Hi, In your python...-solve' error will be solved. Thanks...ModuleNotFoundError: No module named 'sudoku-solve'  Hi, My Python
ModuleNotFoundError: No module named 'sudoku-solve'
;sudoku-solve' error? Thanks   Hi, In your python...-solve' error will be solved. Thanks...ModuleNotFoundError: No module named 'sudoku-solve'  Hi, My Python
ModuleNotFoundError: No module named 'flood-solve'
;flood-solve' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'flood-solve'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named
Permgen error
Permgen error  hi how can i solve permgen error
please solve this program
please solve this program  Build a package EMPPACK that contains one stored function Validatesal() and two stored procedures Insertemp... an exception with an error message -?Salary Out of range?.The Getemp_deails
A Program To Solve In Java
A Program To Solve In Java  x!/x+(x+2)!/x+(x+4)!/x ... (x+n)!/x
Xampp Error Apache shutdown unexpectedly - Solved
Xampp Error Apache shutdown unexpectedly - Solved
how to solve an internet connection problem
how to solve an internet connection problem  when i run my application it give me this error: Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not yet implemented the problem is that i don`t know

Ads