[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [java] Exception in thread "main" java.lang.NoSuchMethodError: main



On Fri, 27 Oct 2006 00:08:23 +0200, Michael Schmidt wrote:

> Hej guru'er (Er flertals formen Guri ?) :)
> Jeg prøver at teste en simpel metode, der kompilerer fint men vil ikke  
> afvikles uden brok: "Exception in thread "main"  
> java.lang.NoSuchMethodError: main"
> 
Det er da logik for burhøns:-)
java runtime leder efter en statisk metode med følgende forskrift:
public static void main(String args[]) { ... }
Svarende til, dog på symbolsk niveau, man i sin tid skulle startadressen i
et assembler program. Java er 100% OO, og da man kun kan afvikle
instruktioner i et objekt, skal java have et fikspunkt i klassen, udformet
som en statisk metode, der skal have ovenstående forskrift. Dette er så
også den eneste metode, der kan kaldes udenfor objekt scope.

> 	public void Main()
Prøv i stedet for
public class MyTest
{
        String t1 = "exercise";
        String t2 = "exercise";
        String t3 = "eksercize";

        public boolean myEqual( String s1 , String s2 ) {
                if ( s1.length() == s2.length() )
                        return true;
                else return false;
        }


        public void Main()
        {
                System.out.println(myEqual(t1,t2));
                System.out.println(myEqual(t1,t3));
        }

        public static void main(String args[]) {
            MyTest myTest = new MyTest();
            myTest.Main();
        }
}

Herudover forstår jeg ikke, hvorfor du lader din klasse eksplicit extende
fra Object? Alle klasser i Java extender implicit fra Object i forvejen.

-- 
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-11-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *