473,322 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how can we write a class in an interface

can we write a class in an interface
Sep 6 '07 #1
7 2261
r035198x
13,262 8TB
can we write a class in an interface
Why don't you try it and tell us what happens?
Sep 6 '07 #2
praveen2gupta
201 100+
can we write a class in an interface
Hi
Interface is also a sort of class. when you compile you will get a .class file.
as for your question we can not write a class in an interface.
Sep 6 '07 #3
JosAH
11,448 Expert 8TB
Hi
Interface is also a sort of class. when you compile you will get a .class file.
as for your question we can not write a class in an interface.
Expand|Select|Wrap|Line Numbers
  1. interface Cii {
  2.  
  3.     public class Foo {
  4.         public void talk() { System.out.println("foo!"); };
  5.     }
  6.  
  7.     Foo makeFoo();
  8. }
  9.  
  10. class FooMaker implements Cii{
  11.  
  12.     public Foo makeFoo() { return new Foo(); }
  13. }
  14.  
  15. public class CinI {
  16.  
  17.     public static void main(String[] args) {
  18.         (new FooMaker()).makeFoo().talk();
  19.     }
  20. }
  21.  
kind regards,

Jos
Sep 6 '07 #4
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1. interface Cii {
  2.  
  3.     public class Foo {
  4.         public void talk() { System.out.println("foo!"); };
  5.     }
  6.  
  7.     Foo makeFoo();
  8. }
  9.  
  10. class FooMaker implements Cii{
  11.  
  12.     public Foo makeFoo() { return new Foo(); }
  13. }
  14.  
  15. public class CinI {
  16.  
  17.     public static void main(String[] args) {
  18.         (new FooMaker()).makeFoo().talk();
  19.     }
  20. }
  21.  
kind regards,

Jos
Y A T F E

P.S The E is for "example"
Edit: And the Y is not for You
Sep 6 '07 #5
JosAH
11,448 Expert 8TB
Y A T F E

P.S The E is for "example"
Edit: And the Y is not for You
Yet Another Truely Fabulous Example?

kind regards,

Jos ;-)
Sep 6 '07 #6
madhoriya22
252 100+
Y A T F E

P.S The E is for "example"
Edit: And the Y is not for You
Hi,
I almost get it "yet another totally F(no guess) example" :)
Note : I m sure T for time is not correct.

Sorry Jos a bit late :)

oops ! completely wrong ....
Sep 6 '07 #7
r035198x
13,262 8TB
Yet Another Truely Fabulous Example?

kind regards,

Jos ;-)
Close.

Yet Another Talking Foos Example.
Sep 6 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
9
by: James Marshall | last post by:
I'm writing a library where I want to override document.write(), but for all document objects; thus, I want to put it in the prototype. I tried Document.prototype.write= my_doc_write ; but it...
8
by: Zheng Da | last post by:
I don't know where should I ask the question, so send the email to this group. I choose this group, because I want to write the program with c++ :) I want to write a program which support...
1
by: Howie (remove _) | last post by:
Hi, there are some ways to write a plugin with C++/.NET. - DLL - COM - .... What do you think is the best (most easiest ?) way to write plugins ?
5
by: Michael | last post by:
Hello, I have a separate Database class that handles any database work that all my asp.net pages can use. My problem is, many times I use try/catch to catch errors, and I want to output these...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.