Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:06:10+00:00 2026-06-17T11:06:10+00:00

Hello there im having a little problem here, i am trying to call a

  • 0

Hello there im having a little problem here, i am trying to call a random number generated in another class and display it via jlabel in 2nd class (jform) and i am sort of lost. number generating is double.
code

GaussianGenerator num = new GaussianGenerator();//calling another class
CriminalDetails() 
{
    initComponents();
    double number = 0;
    num.GaussianGenerator(number);
    CriminalID.setText(Double.toString(number));//CriminalID jfield
}

The number im getting on jfield is the 0 initialized in “double number” but i want to get number generated in GaussianGenerator class.
Thank you for having a look and your time, help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:06:11+00:00Added an answer on June 17, 2026 at 11:06 am

    num is an instance of the number generator. You should be setting the value of number by calling a method on the instance of the number generator object and assigning it to number. Like this (I am not familiar with your other class):

    GaussianGenerator num = new GaussianGenerator();//calling another class
    CriminalDetails() 
    {
        initComponents();
        double number = 0;
        number = num.getNextValue();
        CriminalID.setText(Double.toString(number));//CriminalID jfield
    }
    

    Or is GaussianGenerator is also the name of the method? Bad idea from a design standpoint. Rather than passing it to the method as a paremeter, the method should just return the generated value:

    numer = num.GaussianGenerator();

    In Java you can’t pass a primitive by reference if that is what you are trying to do. You can do this with objects (e.g. Double), however, but that is bad design since a double will suffice. You should also read a good tutorial on Java coding conventions so you can learn how to properly name and capitalize methods. So you would see that this is better coding:

    number = num.getNextValue();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello there i am having little problem. I have two tables in my database.
Hello there i'm having a problem here i have an add and edit form
Hello @ All out there :) I am having a little problem. I want
Hello there im having problem whenever i press the refresh button it keeps adding
I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
Hello is there a class that does a pretty conversion?
Hello I´m trying to automate AZURE VM management like Amazon EC2. Is there any
. Hello, I'm using jqueryui's datepicker, and it works great but there's a problem.
Hello everyone I been trying get php uploader working but having a lot of
Hello there I am having some thoughts on my file structure in codeigniter.What I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.