Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Passing as a parameter, an object + another variable

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing as a parameter, an object + another variable

    I'm have trouble an object which has three integer values in it along with another parameter which is simply a double. This is my syntax atm:

    Object newObject = new Object((1,-2,35),.5);

    I'm not sure how this is supposed to be written out in order for the object to accept it. Thank you in advance for any assistance you may provide!


  2. #2
    Elite Member curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,132
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Passing as a parameter, an object + another variable

    No, you cannot have nested parenthesis like that. Perhaps all you need to do is to remove the inner nested parenthesis and this will work. The key will be to inspect the constructors available for this class and to call one of them appropriately. By the way, hopefully your class is not named "Object", right?

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Passing as a parameter, an object + another variable

    Nah it isnt called object, im just generalizing the statement...but i checked out the constructor and it seems to be in the correct order and the parenthesis idea didnt work

  4. #4
    Elite Member curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,132
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Passing as a parameter, an object + another variable

    Um.... care to share the constructor with us?

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Passing as a parameter, an object + another variable

    public class Object {
     
    	private Coord3D origin;
    	private double intensity; // In range [0..1]
     
    	public Light (Coord3D origin, double intensity) { 
    		this.origin = origin;
    		this.intensity = intensity;
    	}

  6. #6
    Member
    Join Date
    Jul 2012
    Posts
    37
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Passing as a parameter, an object + another variable

    Wouldn't it just be:

    Light light = new Light(new Coord3D(object), 5);

    ??

  7. The Following User Says Thank You to Tyluur For This Useful Post:

    curmudgeon (December 11th, 2012)

  8. #7
    Elite Member curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,132
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Passing as a parameter, an object + another variable

    Indeed you would need to pass a Coord3D object into the Light constructor, likely

    Light light = new Light(new Coord3D(1, -2, 35), 0.5);

    Or something similar.

  9. #8
    Junior Member
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default aRtpspu

    User | ameliawhip | housecrow
    Stuart Speed - Male - Philippines » - BNF
    FIASD - Framing Thy Temper - Berry Meals
    Bookmarkshub - acai berry pareri
    Vasemmiston intranet: Mario
    EQUAL: Personal profile: Edwin Fulton
    Singles Match Link Online Networking and Socializing Community
    User:MarkusAzp - WDW History
    YRFDevin: acai berry thin forum
    Barta Vubon | Search Results for
    TerrellDas:
    acai berry forum | Cimic Bookmark
    Grover Coy - Male - Germany Kumusta-ka ...one community , unlimited connections
    Free Classified Ads
    ensynefo.com - Blog View - The Acai Berry Natural Benefits
    Acai Powder Berry Dietthe Road In Order To Efficient Kilograms Loss | Home | Events in Indianapolis
    RalfACRZ - MyWiki
    Usu�rio:SolfuruA34 - felipeguimaraes.cc
    The Acai Berry Genuine Bulk Imparts Hyaluronic Acid Serum Not To Mention Powder » Friends Brasil - Powered By phpFox
    Benutzer:KelliQUS ? Gleepedia
    WV Combat Sports Competitors | Groups | Precisely Acai Fruit Flesh Thin Facilitates In Day-To-Day Life . Extra Inches Around Your Waist | Home
    The Actual Health Of Acai Juice Berry Nutritional Blog
    InLocalTV.com: Kandace
    The Very Top 5 Acai Berry Elements » El Korillo Latino
    Herbal Medicines Comprehensive Database Acai Monograph | Home |
    Charley68Y:
    Acai Berries Berry Liquid Has Plenty Benefits | Home |
    Acai Juice Berry Guarantees Weight Loss With Nature's Goodness | www.jumpingforfunaroundtheworld.com
    Acai Fruit Berry Buy » GayNetwork
    GoldenPhrog: Acai Fruit Berry Outside Effects Stunning!
    http://jabiru.offersbookmarks.com/us...ile/mikkirich/
    User | ardisi86 | Cimic Bookmark
    Deciding To Buy For A Correct Remarkable Eye Contra- Aging Dofollow Article Directory
    User:SherleneLu - BMRWiki
    http://bookmarks.thelloyds.net/searc...%20thin%20pret
    Acai Berries Berry To Help You Keep You Have To Young As Well As A Healthy » Autism Functions
    Bruce Janssen - Male - Australia » Societ� Italiana on line
    Libreland: Acai Berry As Well As , Weight Loss
    acai berry: http://acaiberry-romania.com/ - link at FacePanel
    UtentehilomenaC - WikiColore
    I-40 Social Network: Monserrate
    Do Acai Fruit Supplements Really Work | Get Smarq Community
    dRbuku - Member Profile - Kerri Harvey
    User | blakedfa | camouflagegreen
    community for all and special for Armenian people
    Morning Dose Coming From All Acai Maqui Berry Information » It Pays to Have Friends! - Powered By phpFox
    StellaAgua - ruokahaaste
    ?????:RoxanaHzu ? ???????????
    Can Do Acai Berries Choose Massively Match » Cybernet
    Shake Acai Fresh Fruit Juice That Can Prevent A Malignant Tumor | Home | FreakyTattoo

Similar Threads

  1. Method calculate 2 object using constructor with parameter
    By DavidXCode in forum Object Oriented Programming
    Replies: 2
    Last Post: November 21st, 2012, 08:31 PM
  2. Need help with passing user defined variable in SQLJ
    By redkryptonite in forum JDBC & Databases
    Replies: 1
    Last Post: March 7th, 2012, 04:47 AM
  3. Need help with parameter passing in my project? (Beginner)
    By xlFireman in forum What's Wrong With My Code?
    Replies: 9
    Last Post: January 14th, 2012, 12:10 AM
  4. Passing JTextField as String parameter
    By Christophe in forum Java Theory & Questions
    Replies: 3
    Last Post: April 11th, 2010, 05:32 AM
  5. Passing objects as a constructor parameter
    By derky in forum Object Oriented Programming
    Replies: 2
    Last Post: October 27th, 2009, 04:31 AM