Why constructor do not have return type

Why constructor do not have return type

enter_name wrote:
Because it only returns one thing: A reference to itsself.This is not quite true. It's the new operator that constructs the object and returns the reference. When new invokes a constructor the object is already partially constructed.
Well, constructors may actually return something but if they do it's a secret between them and new. Constructors cannot be called by the programmer like methods. They don't even belong to the class. They're only used during object construction and then by new.

Similar Messages

  • Why constructors doesn't have a return type ??

    Hi Friends,
    Java objects contains constructors, where we can specify access specifiers but not a return type.
    What's the reason for behind this ??
    Thanx ..
    bala

    class TheoreticalClass {
      // constructor
      public int TheoreticalClass() {
        return 0;
    ? = new TheoreticalClass();Now, would you prefer to have the object reference or the return value?

  • Why Constructor has not return type ?

    Please tell me why constructor has not return type ?

    Constructor is a method which basically called for creating instances of an object. 
    It should return an instance of the class whose constructor we are calling.
    So basically the return type is implicit.
    If the syntax allows to specify return type, users may put some other return types other than the containing class type, which is not relevant.
    Muthukrishnan Ramasamy
    net4.rmkrishnan.net
    Use only what you need, Reduce global warming

  • I have a Macbook Pro june 2011... I have 8GB ram but I only have 256mb VRAM... I've read some other questions about this and I realized... Why do I not have 560mb of VRAM since I have 8GB of RAM? Is there any way to get more VRAM to play games on steam?

    I have a Macbook Pro june 2011... I have 8GB ram but I only have 256mb VRAM...
    I've read some other questions about this and I realized... Why do I not have 560mb of VRAM since I have 8GB of RAM?
    Is there any way to get more VRAM to play games on steam?
    I've learned  by reading other topics that I can't upgrade my graphics card on my Macbook Pro because it's soldered into the motherboard or somthing like that, but please tell me if there is any way to get more video ram by chaning some setting or upgrading something else. I'd also like to know why I only have 256MB of VRAM when I have 8GB of RAM, since I have 8GB of RAM I thought I was supposed to have 560mb of VRAM...
    So the two questions are...
    Is there any way to upgrade my VRAM, so that I can play games on steam?
    Why do I only have 256MB VRAM when I have 8GB total RAM?
    Other Info:
    I have a quad core i7 Processor.
    My graphcics card is the AMD Radeon HD 6490M.
    I am also trying to play games on my BOOTCAMPed side of my mac, or my Windows 7 Professional side.
    THANK YOU SO MUCH IF YOU CAN REPLY,
    Dylan

    The only two items that a user can change on a MBP are the RAM and HDD (Retinas not included).  You have what the unit came with and the only way you will be able to change that is to purchase a MBP with superior graphics
    If you are very much into gaming, the I suggest A PC.  They are far superior for that type of application to a MBP.
    Ciao.

  • A constructor cannot specify a return type.

    I have a shuffleList.as file with this code...
    package {
    import flash.display.MovieClip;
    public class shuffleList extends MovieClip{
    function shuffleList(arr:Array):Array{
    var shuffled:Array = arr.slice();
    for (var i:int=0; i<arr.length; i++) {
    var element:Object = shuffled
    var rnd:int = Math.floor(arr.length * Math.random());
    shuffled = shuffled[rnd];
    shuffled[rnd] = element;
    return shuffled;
    In the first frame i put this code...
    import shuffleList
    var numA:Array = [0,1,2,3,4,5,6,7,8,9,10]
    var numB:Array = shuffleList(numB);
    var myText:String = numB.pop()
    fieldA.text = myText
    With this code I want to put in random order the numbers from
    0 to 10 in the fieldA.
    When run this file the compiler report this error: "A
    constructor cannot specify a return type."
    Where I'm wrong;
    I'm new in actionscript..
    Please help...

    Hey Petros,
    I had a similar problem and the response I got was:
    1) the constructor is used to set up the class but it doesn't
    really exist until it is instantiated and therefore cannot include
    any 'interaction' including a return.
    2) Therefore, you might try replacing
    function.shuffleList ... with
    function.shuffleList() { // to enable instantiation
    public function doit(arr:Array):Array { // to enable
    interaction
    The rest of the code follows this then the call in the first
    frame replaces
    var numB:Array ... with
    new shuffleList(); // instantiate the class
    var numB:Array = shuffleList.doit(numB) // interact with the
    class
    Let me know how it goes...Daniel

  • I am having an old ID on apple but did not have any type of card so what your problem

    I am having an old ID on apple but did not have any type of card so why can not I use it

    If you only want the free apps, take a look here:
    http://support.apple.com/kb/HT2534
    Read the steps carefully as the order in which you follow them is critical. Note that you can do this only when creating a new Apple ID. You cannot use an existing ID.  
    Regards.
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Communities page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums and in the Apple Knowledge Base, before you post a question.

  • How can I use a COM object that does not have a type library?

    Hello,
    I've created a com server in python for which I do not have a type library. I am able to call functions for this application in Python, TCL, I'm sure VB, etc. without the type library.
    Must I have a type library registered to use this COM object with Labview? I was hoping I could simply supply the name to the refnum (or the GUID) then call functions by passings strings to the invoke node. This does not seem to be possible - am I missing something?
    In the event that I cannot use a com server without a type library. Any recommendataions on how to create one? I'm wondering if I can use the same GUID and create a shell in LabWindows which generates the IDL/TBD file I need for Labview to see my
    com server.
    Any help is greatly appreciated.
    73,
    Timothy

    Timothy Toroni wrote:
    > Thanks for the info, however their example is labview server and
    > python client. I'm going the other way. It's good to know about
    > LabPython though...
    >
    > As of now, it seems to be there is no way to use a COM object without
    > a type library from inside LabView.
    Yes that is true. LabVIEW needs that to configure the Property and
    Methode Nodes correctly. Otherwise it would need to have a special
    Property and Method Node with a configuration dialog similar to the Call
    Library Node, but a LOT more complicated. Not sure many people could
    make use of that, and it would be a very tiring experience trying to get
    things setup in that way, by going through the edit, test, and crash
    cycle over and over again.
    Rolf Kalberm
    atter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Why do i not have permission to view a file on my mac?

    Why do i not have permission to view a file on my mac?

    Back up all data. Quit Preview if it's running.
    Hold down the option key and select Go ▹ Library from the Finder menu bar. From the Library folder, delete the following items, if they exist:
    Caches/com.apple.Preview
    Containers/com.apple.Preview
    Preferences/com.apple.Preview.LSSharedFileList.plist
    Preferences/com.apple.Preview.SandboxedPersistentURLs.LSSharedFileList.plist
    Saved Application State/com.apple.Preview.savedState
    Launch the application and test.

  • Why T60 do not have S-video?

    To my amazement I have found that there is no S-Video port in T60 that I bought in Jan'08. I was so disappointed to find out, that there is no way that I can connect my laptop with my TV(except buying new hardware- which is of course not a good option). I was using T43, my company’s laptop and I was impressed with the performance, so I bought T60 for me without noticing and checking that there is no S-video port. I bought without checking because I had full faith in Lenovo, after all, it's a BRAND.!!!!! (I doubt now) and the one T-series that I was using have every such thing.
    Later, I wanted my T60 to connect to my TV. I searched over the internet and reached to a conclusion that I need to buy more hardware, just because T60 do not have S-Video.  WHY?
    Why T60 do not have S-video port? Is there any other way to connect it to my TV(without buying new hardware)?
    Also I want to highlight that the sound quality and the volume level is the poorest of all the notebooks I have seen so far. Now I am regretting why I bought this machine.
    Even fingure print login is starting malfunctioning, I dunno why but when I start the window with the alternate password it keep asking for figure print and the small window get stuck on the desktop.
    Hoping to get some sympathy  atleast, for buying such a horrible machine.

    Not a good sign. If the following does not resolve the problem then it is a hardware problem and an appointment at the Genius Bar of an Apple store is required.
    iOS: Wi-Fi or Bluetooth settings grayed out or dim

  • HT1338 why I do not have Bonjour under bookmark in my safari on Macbook pro?

    Hi, I am using a Macbook Pro, I wonder why I do not have Bonjour in the bookmark tab in safari?
    I need it to install a Pioneer wireless speaker with AirPlay.

    Go to Safari Preferences/Bookmarks and Select Bonjour in Collections.

  • HT5457 why i do not have face time in my iPhone

    why i do not have face time in my iPhone

    If you still have iOS6 then there is no stand alone Facetime App.  It is integrated through the Contacts App.
    If you have iOS7 it should look like this:
    Make sure its not restricted and is not hidden in a folder or another screen.

  • Why we do not have "hotspot Wi-Fi" in IPad IOS6?

    Why we do not have "hotspot Wi-Fi" in IPad IOS6?

    Because the iPad 2 does not have the correct hardware. The new ipad (iPad 3) has the correct hardware.

  • Why I do not have Siri on my ipad2

    Why I do not have Siri on my ipad2

    Apple never said Siri would be on the 2. In fact, they've said since the announcement of iOS that it would not be on the 2. It's safe to say that if it's not on there now, it never will be on there.
    If Siri is a make it or break it for you, then your choices are to upgrade to a newer model that has the necessary hardware to make the program run right.

  • Why does lion not have front row

    why does lion not have front row
    and what can i do to get it i loved the ease of use

    Front Row is not included or supported in Lion.
    Read here, but proceed at your own risk

  • Why would I not have sufficient privleges on my own computer to start Apple Mobile Device Service?, why would I not have sufficient privleges on my own computer to start Apple Mobile Device Service?

    I performed the most recent update of iTunes, but it did not install properly. I uninstalled iTunes, then reinstalled, but now I am getting an error that states: "Service 'Apple Mobile Device' (Apple Mobile Device) failed to start. Verify that you have sufficient privleges to start system privleges." I am the owner of this computer and do not understand why I would not have sufficient privleges to start a service on my computer. Any help would be very much appreciated!
    Mike

    Solving the iTunes Installation Problems in Windows
    1. Apple has posted their solution here: iTunes 11.1.4 for Windows- Unable to install or open - MSVCR80 issue.
    2. If the Apple article does not fully resolve the problem for you, then try Troubleshooting issues with iTunes for Windows updates - MSVCR80.
    iTunes 11.1.4 for Windows- Tips for Unable to install or open - MSVCR80

Maybe you are looking for