|
Yes, but there is also polymorphism as jschell said: Thread thread = new MyThread. I just got the assignment backwards. To me it is more logical to think of a=b instead b=a.
|
|
|
|
|
Thread thread = new MyThread();
...works, cause Thread is the parental to MyThread .
Using that leaves you with the basic functionality that is given in Thread (unless you cast Thread to a MyThread, then you'll be able to access the additional functions).
You could add additional functionality to any Object when you extend it - which is the basic meaning of extension.
So when initializing the Object you will have to choose the right one - the parental Object does not own the additional methods, does not know them.
You would not be able to access them.
Example:
public class Vehicle{
}
public class Bus extends Vehicle{
public int getSeatQuantity(){
}
}
A vehicle can be anything from a bike up to a race car, truck, even a train.
It's not important for a bicycle or a race car how many seats it has. But it's important for a bus.
So when you want a Bus (...and later probably know how much seats are available) you will have to create a Bus and not just a Vehicle .
Simple said: it's more specific.
|
|
|
|
|
You've got the idea now, but consider this as another way of looking at it:
a MyThread is a Thread and then some. If you had added extra class members - code or data - in the definition of MyThread , it would have stood out like the proverbial.
Another clue is in Java's use of the keyword extends .
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
A super class reference variable has the capability to hold its sub class object but a sub class does not have that capability.
As MyThread is subclass of Thread, you can write
Thread t=new MyThread();
But not
MyThread m=new Thread();
That's false.
|
|
|
|
|
Hi! every body i am very new to this and i need an help to start implementation of my idea
i need an application that has to the following things
1.it has to store all messages that came to my mobile
2.store them in a database the msg contains a mobilenumber date time and msg text
3.shedule and send them to that number at that time and date given in msg through my mobile number
please help if it possible any one has a solution
sagaram
|
|
|
|
|
Nothing that would make it implicitly impossible although running a database on a mobile without qualifying both of those is unlikely to be generally true.
ask.sagaram wrote: any one has a solution
Solution
1. Investigate mobiles
2. Investigate databases on those mobiles
3. Pick a mobile and database (from 1 and 2)
4. Learn how to code database code on a mobile
5. Learn how java networking works and probably networking in general
6. Learn how SMS works.
7. Learn how SMS works on a mobile (which probably goes back to 1.)
8. Write code to do SMS for the mobile.
9. Combine all of the above into an application.
|
|
|
|
|
|
Hi
I have to display a DIB image in java applet through AWT Native interface. I have been able to play a live video using this technology but drawing an image is taking too long especially when the conversion of a DIB image is very difficult.
Any help in this regard would be helpful
|
|
|
|
|
I don't know if this might sound silly, but is it possible to interact with hardware(say an audio card in my case) using Java.
The master of the art of living makes little distinction between his work and his play, his labor and his leisure, his mind and his body, his education and his recreation, his love and his religion. He hardly knows which is which; he simply pursues his vision of excellence in whatever he does, leaving others to decide whether he is working or playing. To him he is always doing both.
|
|
|
|
|
Yes, it is possible. However, without a lot more information it's impossible to suggest much more than that. If you have a specific question then please update your post above with the details.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Quote: without a lot more information it's impossible to suggest much more than that.
Yeah, I am sorry, but I have been asked to develop it in Java. I have used C++ before for sound operations using mmioAPIs but this project that I am going to work on contains several modules and one of the module is signal(generated by a digital hardware component) recording and replaying through different channels of a DAC card. Can this be done in Java? Anyway, the GUI of the application software should be written Java. This is must and should. I am new to Java and I use Eclipse IDE.
And I didn't down-vote you. Countered.
The master of the art of living makes little distinction between his work and his play, his labor and his leisure, his mind and his body, his education and his recreation, his love and his religion. He hardly knows which is which; he simply pursues his vision of excellence in whatever he does, leaving others to decide whether he is working or playing. To him he is always doing both.
|
|
|
|
|
stib_markc wrote: And I didn't down-vote you. Thanks, but don't worry about it, a few downvotes never hurt anyone.
As to your main question I have not looked at the links that the other guys have offered but they may answer your query. I have worked on similar projects in the past and found the best solution was to write the low-level stuff in C/C++ and use the Java Native Interface[^] to access it from the Java application.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
|
Thank you, I will look into it and get back.
|
|
|
|
|
Sound is a bit of a problem, most of the support has been turned down.
But yes, check this: [Java Sound API[^] @ oracle.com
|
|
|
|
|
In worst case you can implement your interaction in C/C++ modules for each supported platform and you can bind your native code to java via native method calls but thats a lot of work especially if you have a lot of different platforms to support. But you can reach any platform specific functionality from java if you are willing to write some platform specific C/C++ for it. In your case I would go with the sound api the guys already linked if its enough to get the job done.
|
|
|
|
|
Native methods in Java? I have to learn about them.
The master of the art of living makes little distinction between his work and his play, his labor and his leisure, his mind and his body, his education and his recreation, his love and his religion. He hardly knows which is which; he simply pursues his vision of excellence in whatever he does, leaving others to decide whether he is working or playing. To him he is always doing both.
|
|
|
|
|
You can declare a static or instance method in java and by applying the native keyword on it you indicate for the compiler that you will provide the implementation with native code, and not in java. Then you have to write a DLL (or more DLLs) that exports the native function(s) with the appropriate names. When you java program starts you have to load the needed DLLs with System.LoadLibrary() before you call the native methods. Example: http://www.javaworld.com/javatips/jw-javatip23.html[^]
I would note that you should always try to write as much code in crossplatform java as you can and don't use native methods if you can avoid them because platform dependent stuff defeats the purpose of java.
|
|
|
|
|
hey guys,can you make an array without a length.?
|
|
|
|
|
int arr[]=new int{1,2,3,4};
|
|
|
|
|
|
I have an application where I need to send the values from java applet code to html page. Please help me to send the values from java code to HTML page(may be using javascript)
My java code is,
public class Calc extends Applet
{
public int tot = 0;
public void paint(Graphics g)
{
int M1 = Integer.parseInt(this.getParameter("m1"));
int M2 = Integer.parseInt(this.getParameter("m2"));
int M3 = Integer.parseInt(this.getParameter("m3"));
int M4 = Integer.parseInt(this.getParameter("m4"));
int M5 = Integer.parseInt(this.getParameter("m5"));
int M6 = Integer.parseInt(this.getParameter("m6"));
tot=M1+M2+M3+M4+M5+M6;
this.setParameter("tot",Integer.toString(tot));
g.drawString(Integer.toString(tot), 10, 10);
}
}
|
|
|
|
|
I have this very urgent requirement of developing a code that can extract .mp3 from .flv . I have had partial success in extracting raw bytes of mp3 from it . Now why is it that when i use something like
FileOutputStream fout=new FileOutputStream("dude.mp3");
fout.write(buffer,0,len);
assuming that buffer contains all the bytes of extracted mp3 .
Can somebody perhaps give me an alternate approach which does not involve using ffmpeg . I just want to work with bytes (it's a requirement and also no external apis).
|
|
|
|
|
Member 9459463 wrote: I just want to work with bytes (it's a requirement and also no external apis). Why start by setting restrictions rather than investigating what tools are available that may help to solve your problem?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
It's an interview question .
|
|
|
|