Interface in java

I hava an Interface having two methods in it.I wanted only one method in a class. I declared that class as abstract for the purpose.But its not possible for me to view that method through the class, since it is abstract(class connot be initiated).Please sent me a relevent code or example for this problem

[312 byte] By [Raheshrsa] at [2007-10-3 3:20:10]
# 1

Its not a problem. You cannot instantiate an abstract class period. What you do is you create a subclass (possible multiple subclasses) that implement all abstract methods, in this case the interface method that is still missing. Then you create instances of that subclass, which also allows you to call the method from the abstract base class.

gimbal2a at 2007-7-14 21:12:19 > top of Java-index,Java Essentials,New To Java...
# 2
How to implement a abstract class?
Raheshrsa at 2007-7-14 21:12:19 > top of Java-index,Java Essentials,New To Java...
# 3

> How to implement a abstract class?

Use the abstract keyword:

public abstract class Foo {

}

There you have it, an abstract class.

BillKriegera at 2007-7-14 21:12:19 > top of Java-index,Java Essentials,New To Java...
# 4

I believe he is asking how to actually implement the abstract class.I would highly suggest reading up on the java tutorials here or picking up Head First Java

public class Bar extends Foo{

// be sure to implement all abstract methods not previously implemented

// in Foo

}

Message was edited by:

eko291

eko291a at 2007-7-14 21:12:19 > top of Java-index,Java Essentials,New To Java...
# 5
Just to point out one more thing. You "implement" an interface and "extend" a class. Once you created the abstract class, you need to extend that class to make all of the methods concrete.
eko291a at 2007-7-14 21:12:19 > top of Java-index,Java Essentials,New To Java...
# 6
Thanks, I got it
Raheshrsa at 2007-7-14 21:12:19 > top of Java-index,Java Essentials,New To Java...