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 6954231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:34:46+00:00 2026-05-27T14:34:46+00:00

I have created a new class ‘ServiceRequest’ like below. I have not added getters

  • 0

I have created a new class ‘ServiceRequest’ like below. I have not added getters and setters here to save space.

package testListenerPackage;

import java.util.Date;

public class ServiceRequest {

public static final ServiceRequest REQUEST_ARRIVAL   = new ServiceRequest( "Request_Arrival" );
public static final ServiceRequest REQUEST_COMPLETION   = new ServiceRequest( "Request_Completion" );
public static final ServiceRequest REQUEST_UNDER_PROCESS = new ServiceRequest( "Request_Under_Process" );


private String serviceRequest;
private String requestName;
private int requestID;
private long arrivalTime;
private long startServiceTime;
private long endServiceTime;
private long totalServiceTime;

private String requestStatus;

public enum RequestStatus{
    NEW, COMPLETED
}



public ServiceRequest()
{

}
public ServiceRequest( String serviceRequest ) {
    serviceRequest = serviceRequest;
 }
}

When I try to create an instance of this object in other class like this, it returns a null object.

  public ServiceRequest generateServiceRequest()
{
    ServiceRequest serviceRequest = new ServiceRequest("Ali baba");
    serviceRequest.setRequestID(1);
    serviceRequest.setRequestName("Read");
    serviceRequest.setRequestStatus(ServiceRequest.REQUEST_ARRIVAL.toString());
    serviceRequest.setArrivalTime(System.currentTimeMillis());
    return serviceRequest;
}

Can anybody tell me what to do?

  • 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-05-27T14:34:46+00:00Added an answer on May 27, 2026 at 2:34 pm

    I don’t like this code:

    public ServiceRequest()
    {
        // all those references are null - crazy
    }
    public ServiceRequest(String serviceRequest ) {
        // use "this" to clarify what's initialized
        this.serviceRequest = serviceRequest;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to iphone development.I have created a UIview controller class and added
Following on from another question I have asked I have created a new class
I have created a new control VidController public class VidController : Controller { public
I have created a new migration: class AddSignatureToUser < ActiveRecord::Migration def self.up add_column :users,
I have a WPF application, i created a new class named Agent . On
I have created new class to read the data from xml file, which looks
I have created new class which handles button. It does nothing (just for test,
I have a ghashtable object as member of my class. I have created new
I have created a new wcf4 web application and added a new wcf service.
I have created a new iPhone project in Xcode 4 and added some files

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.