Results 1 to 3 of 3
Like Tree2Likes
  • 2 Post By doWhile

Thread: public instance method

  1. #1
    shandyding is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default public instance method

    can someone tell me how to write code for this r what it should look like.

    public instance method called coinToss() which takes no arguments and
    returns either true or false as the result. The method should simulate the tossing of a
    fair coin, returning true to represent the result of the coin toss being heads and false
    to represent tails.

  2. #2
    diamonddragon is offline Senior Member
    Join Date
    Jan 2012
    Posts
    210
    Rep Power
    3

    Default Re: public instance method

    Hope this will help:
    Java Code:
    Random r = new Random();
    boolean output = r.nextBoolean();

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    6

    Default Re: public instance method

    Quote Originally Posted by shandyding View Post
    can someone tell me how to write code for this r what it should look like.
    Judging from this and your other posts you seem to misunderstand these forums to be a code service/repository, which they are not. I suggest you ask a specific question, and define what is confusing about the requirements - what you have tried, what you have read, and then go from there.
    Fubarable and DarrylBurke like this.

Similar Threads

  1. passing percent to public int method
    By BillyB in forum New To Java
    Replies: 3
    Last Post: 02-04-2011, 06:08 AM
  2. Using an Instance method
    By Thumper in forum New To Java
    Replies: 4
    Last Post: 12-09-2009, 06:43 PM
  3. Public static method error
    By leapinlizard in forum New To Java
    Replies: 5
    Last Post: 04-29-2009, 11:10 PM
  4. public instance method
    By steve123 in forum New To Java
    Replies: 5
    Last Post: 06-20-2008, 08:45 PM
  5. public method
    By dirtycash in forum New To Java
    Replies: 4
    Last Post: 11-21-2007, 07:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •