Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: i'm getting th error, when i put a method to get the position of the smallest no

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy i'm getting th error, when i put a method to get the position of the smallest no

    public class SmallestIndex {


    //This method returns the index of the smallest value in the array of given size
    private static int arrSize = 0;


    public static void smallestIndex (int[] array) {


    int currentValue = array[0];

    int smallestIndex = 0;

    for (int j=1; j < arrSize; j++) {
    if (array[j] < array[smallestIndex])
    smallestIndex = j;
    }
    System.out.println();
    System.out.println("The smallest index is: "+ smallestIndex);

    }
    }


    it compiles correctly but when run program this error come
    --------------------Configuration: my - JDK version 1.6.0_27 <Default> - <Default>--------------------
    java.lang.NoSuchMethodError: main
    Exception in thread "main"
    Process completed.

    so to correct this when i put the static void main(String[]args) so many other errors come again!!!


    pls help me correcting this... your members help is greatly appreciated..

    thank you!!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: i'm getting th error, when i put a method to get the position of the smallest n

    so many other errors come again!
    What errors? What is within your main method? Post an SSCCE, all the errors, and wrap your code in the code tags.

Similar Threads

  1. method to return the position of the smallest item in an array
    By izzahmed in forum Java Theory & Questions
    Replies: 5
    Last Post: November 4th, 2011, 04:18 AM
  2. method undefined error
    By Herah in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 29th, 2011, 08:38 PM
  3. For each K, output the smallest palindrome larger than K.
    By alekkk in forum Member Introductions
    Replies: 2
    Last Post: July 23rd, 2011, 02:50 PM
  4. [SOLVED] My smallest and largest integers will not change.
    By toiletsauce in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 1st, 2011, 07:50 PM
  5. where is the error in this method !
    By M7MD in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 9th, 2010, 05:08 PM