What for do we need constructor?

Hi I just wonder, if I can have construction like this:
public class MyClass
private int a = 5;
private AnotherClass another = new AnotherClass();
public MyClass()
//absolutely nothing to do in here
}which lets me initialize variables directly in class definition what for do we need constructor? I always thought that we should initialize object via constructor but as java lets us do it without constructor what is the point of having one? Except of course to provide a way to tell compiler that we want another object of this class by saying:
MyClass myClass = new MyClass();Thanks for any answers.

atch7 wrote:
Hi I just wonder, if I can have construction like this:
public class MyClass
private int a = 5;
private AnotherClass another = new AnotherClass();
public MyClass()
//absolutely nothing to do in here
}which lets me initialize variables directly in class definition what for do we need constructor? I always thought that we should initialize object via constructor but as java lets us do it without constructor what is the point of having one? Except of course to provide a way to tell compiler that we want another object of this class by saying:
MyClass myClass = new MyClass();Thanks for any answers.But you do have a constructor. Take your example and do it this way
public class MyClass {
  private int a = 5;
  private AnotherClass another = new AnotherClass();
}As you wanted. Okay, you can do this. No problem. The compiler will add a default constructor for you, so, even though you didn't write one, you still have one.

Similar Messages

  • What cables do I need to connect my 2013 macbook pro to my HD tv? I know I need mini display to HDMI, but male? female HDMI??? and also, do I need a separate cable for sound?

    what cables do I need to connect my 2013 macbook pro to my HD tv? I know I need mini display to HDMI, but male? female HDMI??? and also, do I need a separate cable for sound?

    Actually you need a Thunderbolt to HDMI adapter. It will carry both audio and video.
    This one will work: Mini DisplayPort | Thunderbolt® to HDMI® Adapter w/ Audio Support

  • What cable for macbook pro needed to connect with LCD projector

    I ordered a Mini DVI to VGA adapter, but it doesn't fit into my laptop. What connection do I need for a connection

    if you do not have a Mini DVI, that leaves only about 80 models of MacBooks.
    Which one do you own?

  • I have partitioned my time capsule, but I can't get it to work as a Time Machine back up and permanent media server for both mac and PC. What format do I need to partition the drive to so that it works for both mac and windows and so that it will be visab

    I have partitioned my time capsule, as I want part of it to act as a media server for both mac and windows. However I don't know what format that I need to partition it to. I also can't make it a permanently accesible drive. I want to restore the drive to the original format (which I don't know) and start again and re-partition the drive in a format that can be used for media by both mac and PC and for time machine back-ups and make the media part of it permanetly accesible so I can add and acccess my files.
    Thanks

    You are mixing up a couple of things here.
    The TC drive cannot be partitioned without removing it.. did you do that?
    If you partition it you must use a Mac disk utility and use the HFS+ ie standard Mac format. And GUID partition table not windows type.
    You can select erase disk in the airport utility.. that will take the disk back to original format. No partitions. TC is deliberately not partitioned as it is not a media server.. it is a backup device for TM. Over time .. the disk will be filled with TM backups so you have a long history of file changes to your computer.
    There is no media server in the TC.. it is merely disk storage.. you can serve files from it to a media device.. but the TC itself is dumb as dumb.
    Now the actual format of the drive is irrelevant to the PC.. The TC offers SMB file services to the network. You can copy files to and from the TC as if it was a local disk without caring one iota about the format. The TC handles that .. it is not a local disk .. it is a network drive.
    Although you cannot partition the TC. you can still copy files to it.. this does have implications for TM.. but as long as there is plenty of free space should not be a major issue.
    You can create a disk image via the disk utility in a Mac.. and as stated you can create partitions if you do it on a Mac with the disk directly connected which means breaking warranty if any exists on the TC.

  • What cable do I need for a mac mini with this monitor

    I want a mac mini for christmas, I have a monitor but it only supports VGA, so what cable do i need to get a mac mini up and running on this monitor
    Thanks

    You will need the mini-DisplayPort to VGA adapter cable, here.

  • I am trying to upload itunes 10.5, but get a message "There is a problem with this Window Installer Pkg. A program required for this install to complete could not be run.  Contact your support personnel or package vendor".  What is it I need to do?

    I am trying to install itunes 10.5, but during the download I get the following message, "There is a problem with this Window Installer Package.  A program required for this install to complete could not be run.  Contact your support personanal or package vendor."  If this is my personal computer and was able to upgrade to the previous version (pre 10.5), why not now?  What is my "package vendor"? And what is it I need to do to fix this?  The message is unclear.  Unfortunately, I deleted my itunes program, thinking that in doing so, 10.5 would finally load.  Now I have no itunes on my computer and unable to sync my iphone.  Help!
    Thanks - Rick

    Hi Rick,
    by "repair" I mean I went to the control panel, option - programs and features, and in the list of all my installed programs I selected "Apple Software Update". On top of the screen you find the options Uinstall, Change and Repair. I clicked the repair button and that did the trick. After the repair I could uninstall the program. I also uninstalled iTunes, Apple Application Support, Apple Mobile Device Support en Bonjour, thus all Apple programs. Then I installed iTunes 10.5 again and everything went fine.
    Success,
    Peter

  • Hi i have an ipad mini and i have not used it for 2 month or more. Today i have tried to use it i came across with a problem. my Ipad is blocked and it asks me to wait 23,401,418 :) what should i do need your help. thanks

    hi i have an ipad mini and i have not used it for 2 month or more. Today i have tried to use it i came across with a problem. my Ipad is blocked and it asks me to wait 23,401,418 what should i do need your help. thanks 

    Have you charged ipad Try a Reboot press & hold power button & menu button hold both down until you see Apple Logo You may need to do this more than once. Bsydd uk

  • What are the roles need to add for webservice user in SAP ECC 6.0

    Dear SDNS,
    Can you please help me to understand , what are the roles needed to add while creating a webservice user in ABAP STACK.
    Really appreciate your immediate help and response.
    Thanks and Regards.
    Suraj

    Hi Suraj,
    Please refer to this link & apply the role/s as per the requirements for the web service user:
    [http://help.sap.com/saphelp_nwpi71/helpdata/en/2b/07074155bcf26fe10000000a1550b0/content.htm]
    Best Regards, Trevor

  • So the left side of my iPhone isn't working at all and I even tried turning it off for 5 minutes about 10 million times but nothing is working. Any suggestions on what to do I need help like ASAP!?

    So the left side of my iPhone isn't working at all and I even tried turning it off for 5 minutes about 10 million times but nothing is working. Any suggestions on what to do I need help like ASAP!?

    Have you performed a reset? Tap and hold the Home button and the On/Off button for approximately 10-15 seconds, until the Apple logo appears. Release both buttons and await restart.

  • What technical components are needed for integration of SAP BI and BO?

    Hello,
    What technical components are needed for integration of SAP BI and BO?

    Hi,
    you need to setup a BOBJ server (eg. BusinessObjects Enterprise XI 3.1 or BO Edge 3.1) and then install the BusinessObjects integration Kit for SAP on the same machine your BOBJ server runs.
    In order to build reports you can either use Crystal Reports (eg Install Crystal Report Designer 2008 V1 if you have an XI 3.1 server installed), WebIntelligence (Install the Business Objects XI 3.1 Client Tools in order to be able to build universes), BusinessObjects Voyager or XCelsius. Please note that you have to always install the BOBJ integration Kit for SAP (should be the same version as your server and client installation) on your clients AFTER you installed one or more of the above client tools.
    Please take again a look at the following link for more detailed information (from Ingo) on this:
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a00ee3b2-5283-2b10-f1bf-8c6413e0898f]
    Regards,
    Stratos

  • What are the steps need to be taken care  for MM data sources  while extrac

    what are the steps need to be taken care  for MM data sources  while extracting  from R/3 tables
    and please provide the Steps involved in R/3 side
    thnaks
    Racha

    Hi,
    For Inventory Management, you can have a look at the following link.
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f83be790-0201-0010-4fb0-98bd7c01e328]

  • What are the steps needed to make the field in the DFF Additional Information for Agent only take numbers, commas & hyphens?

    Hello All,
    What are the steps needed to make the field in the DFF Additional Information for Agent only take numbers, commas & hyphens?
    Navigation
    Bob Sales manager<Ebiz form<service request tab<SR type<DFF<additional information for agents <cheque number
    The field Cheque number Character allowed (, -) in the DFF Additional Information for Agent should only take numbers
    Thanks & Regards
    Ayesha

    Thanks Sridar
    If we use Number we cannot separate the cheque numbers with , or -
    We need to enter numbers along with comma and '_' in cheque number field.
    Thanks & Regards
    Ayesha

  • I have a macbook pro 15 inch mid 2012 and I want to change the hard drive, what specifications do I need to search for?

    I have a macbook pro 15 inch mid 2012 and I want to change the hard drive, what specifications do I need to search for?

    Does a Seagate - 1TB Internal Serial ATA III/Serial ATA II Solid State Hybrid Drive for Laptops - Multi with the following specifications may work??
    Height
    4 inches
    Width
    2.75 inches
    Weight
    3.5 ounces
    Color Category
    Multi
    Minimum System Requirements
    PC: Windows XP, Vista, 7 or 8; MacBook®, MacBook Pro or Mac Mini: Intel®
    processor; OS X; Linux; internal Serial ATA III or Serial ATA II support

  • I purchased the 5s yesterday and wanted to dock the phone into my Bose Sound Dock that I use for my IPOD and used for my previous Apple smart phone.  What steps do I need to take to use the feature of Pandora on this IPOD dock

    I purchased a Apple 5s yesterday replacing my two year old Apple 3G.  With my old phone I used it to dock into a Bose Sound Dock to listen to Pandora and other music outlets.  The Bose dock also is used to play my IPOD.  What steps do I need to take to use my new phone on this dock to continue playing Pandora

    This is the only thing I could find but it does not answer my question or even what I was told by the Global Support Rep.
    Verizon has confirmed (here and here) they WILL unlock the SIM on the iPhone 4S, allowing for use of local SIM cards while traveling abroad (no word yet on whether this will allow for use on AT&T and T-Mobile.) This is different than the jailbreak unlocking method; SIM unlocking through Verizon is permanent and will not affect your warranty in any way.
    1. Meet the following requirements:
    * Must be a Verizon Wireless customer.
    * The iPhone 4S being unlocked must be active on a Verizon Wireless line of service.
    * The line of service must be active at least 60 days.
    * The line of service must be in good standing for the past 60 days.
    * Only one SIM Unlock per line every 10 months.
    If you don't meet one or more of the above requirements, call anyway. You may still get lucky.
    2. Insert a foreign SIM into the SIM card slot on the side of your phone (only required to confirm that the unlock is successful.)
    3. Call 1-800-711-8300 (Verizon Global Support) and ask the representative for a SIM unlock. Occassionally a representative may not know exactly what you are referring to; make sure you are not transferred to a different department. You are in the right place. Explain that they should have a walkthrough on how to do this, and that it allows for the use of local, non-Verizon SIM cards while traveling abroad.
    4. Get confirmation from the rep that the unlock has been applied to your account, then check your phone to make sure it recognizes your SIM and can connect (if successful it will roam on AT&T, assuming you are calling from the USA.) You will NOT see an unlock confirmation in iTunes as that is for a factory-applied unlock only.
    5. Enjoy your new unlocked iPhone 4S!

  • What licensing do I need for this use ?

    Lets say Im planning an application which does nothing but
    allows the user to upload Adobe PDF documents to our server. Then
    once on the server, parse the values from forms on the PDF's and
    extract the data. We wont be distributing Acrobat reader or any
    other Adobe product, but will provide a link where they can
    download the reader.
    Also, the PDF's would be created by someone with a copy of
    Acrobat pro. These PDF's will need digital signature capability.
    Can Acrobat reader handle signatures ?
    Here are my questions:
    - What licensing do I need, if any, in the above scenario,
    other than that for a copy of Acrobat ?
    - What are my options for capturing digitical signatures
    within a PDF and will the publicly available version of Acrobat
    reader allow the end user to sign the documents, provided they
    install the extra requirements for handling the signatures ?

    This isn't the correct forum for this topic, but I may be
    able to get you started...
    The licensing restrictions on gathering form data from PDFs
    is outlined in the EULA for Reader, I believe there is a limit of
    500 copies, but I could be wrong ... you should look at the EULA to
    be sure.
    Beyond that, try posting to the
    Acrobat
    Forums or contacting a sales rep at Adobe, they may be able to
    advise you further.

Maybe you are looking for

  • Continual blank registration window preventing startup of Photoshop CS 3 on Mac OS 10.6.8

    I have been using Photoshop CS3 Extended for quiet a while without problems.Suddenly a blank registration window shows up whenever I need to use the program.Because I am unable to do anything with a blank window I cannot dispose of it and I cannot ge

  • AC3 Collison detection inside a movie clip (rather than with its bounding box)

    I want to navigate a maze and therefore I want to create collison detection with the maze itself, but when I try the collison is made with the entire maze movieclip, so even if my character is safe in a corridor without touching the walls of the maze

  • Need to Disable "Create New SmartView Slice" Option in Smart View

    Hi All, We are using Essbase 11.1.2 and we have one Essbase ASO Cube. For accessing that cubes using Hyperion Smartview (11.1.2.1.102(Build 208)). As a security in shared services we have provided only read only access to all users and Users are acce

  • The concept of session in Oracle DB

    Could someone please direct me to any papers/books/documentation that treat the concept of session extensively? I would hope to find there an answer to my previous question (see posting with subject USERENV Namespace: background vs. foreground jobs)

  • Include Opening Balance in XL Report

    In xl Reporter, is it posisble to show the opening balance of an account, i.e. in SAP when you running the trial balance, you get an option to include opening balances.  How can you achieve this in XL Reporter? Any suggestions would be appreciated. S