Static depends of class,as you can see,the class is the caller of forDigit() and floor(), however, you can call those methods with instances of these classes, but is just an illusion, it still cares only about the class, so some principles like overriding and so on won't apply. Also keep in mind you can not call instance ariables or methods inside a static context(methods or blocks), but you can call statics from instance context because statics are shared by all the instances of a class. If a static method sets something, it will apply to all instances of that class, if an instance method sets something,it will only apply for the caller.
On Aug 18, 2:34 am, "David Seto" <[email protected]> wrote: > Identifying static and non-static method I still can't distinguish the two? > > Lab exercise trying to identify the items in bold which one is static and > which one is non-static. > > Could someone explain the difference using those examples listed below? > > // endsWith()method > > String str = "Hello"; > > System.out.println( str.endsWith("slo" ) ); > > //forDigit()method > > System.out.println( Character.forDigit(13, 16) ); > > // floor()method > > System.out.println( Math.floor(3, 14) ); > > //isDigit()method > > System.out.println( "0=" + Character.isDigit('0') ); > > System.out.println( "A=" + Character.isDigit('A') ); --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
