Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners to solve the error
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


lancau
to solve the error
1 Answer(s)      6 years and 3 months ago
Posted in : Java Beginners



Advertisement
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 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
OCI Connectivity For Oracle Plz Solve This Error
) { e.printStackTrace(); } } } ---> I found Error below how i can solve this error plz tell me some answer Package not found Error...OCI Connectivity For Oracle Plz Solve This Error  import java.io.
OCI Connectivity For Oracle Plz Solve This Error
) { e.printStackTrace(); } } } ---> I found Error below how i can solve this error plz tell me some answer Package not found Error...OCI Connectivity For Oracle Plz Solve This Error  import java.io.
Solve it
Solve it  How to calculate the value which contains oparator and operand both using command line argument
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 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
solve this pbm
solve this pbm  its not working the code for databae access using servlets
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
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
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
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
A Program To Solve In Java
A Program To Solve In Java  x!/x+(x+2)!/x+(x+4)!/x ... (x+n)!/x
help me to solve this question
help me to solve this question  Write a program that inputs a series of integers into an array. The numbers are in the range 0 to 100. Calculate and display : a) The Largest number b) The Smallest Number c)The sum of the numbers
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. This type error also comes when java file
please solve the programme
please solve the programme  Develop a java program to find the roots of a quadratic equation ax2+bx+c=0, with the following specification :- Class name :- Quad Data members float a,b,c,d, with a,b,c are the co-efficient
plz solve my query?
plz solve my query?  how to remove all the options from select control in html using java script?   JavaScript remove all items <html> <script language="javascript" > function removeAllItems(selectbox
help me to solve this problem..
help me to solve this problem..  Given below is a class definition for Book. Type and compile the class, and answer the following questions: class Book { String title; //bookâ??s title double price; //bookâ??s price
help me to solve this question...
help me to solve this question...  Given below is a class definition for Book. Type and compile the class, and answer the following questions: class Book { String title; //bookâ??s title double price; //bookâ??s
Solve Program - Java Beginners
Solve Program  Write a progaram in java to display all odd number from 1 to 100   hi use this code package rajanikant.code.sep_2008; public class EvenOdd { public static void main(String s
Solve this problem plzzz
Solve this problem plzzz  Prashant.jsp (this is my JSP file) <HTML> <HEAD> <TITLE>Login using jsp <BODY>... kindly help me and check all those files and solve my problem as soon as possible
Solve it - Java Beginners
Solve it  Hi Friends, Thanks for continue reply.. I have some query please solved...its urgent.. I have two table,emp,exam.both have e... is write here. no information display in the jsp file please solve it and let me
Please Help To Solve My Problem
Play Second Match With Same Team Then Generate The Error... EXAMPLE: A Team Play With B Team when A Team Play With B Team Again Then Generate Error. I Am Solve...Please Help To Solve My Problem  PHP I Have 6 Textbox and 1 ok
 

 

 

DMCA.com