Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Could you explain this?
Robby Ames
Ranch Hand
Posts: 45
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
interface Inter { } class InterfaceTest implements Inter { public void Dsply() { System.out.println("Hi"); } public static void main(String args[]) { Inter obj = new InterfaceTest(); obj.Dsply(); } }
The above code gives
error!!
BUT
The code below runs smoothly!!
interface Inter { } class InterfaceTest implements Inter { public String toString() { return"Hi!!"; } public static void main(String args[]) { Inter obj = new InterfaceTest(); String msg = obj.toString(); System.out.println(msg); } }
WHY??
Tony Docherty
Bartender
Posts: 3323
86
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Mathew Brown already answered your question in the original
thread
https://coderanch.com/t/600404/java/java/Java-Interface#2739537
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Regarding Interface Concept
interfaces used to work on my system but now they dont :)
Interface
Can we define a inner class in an interface?
What does this mean?
More...