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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:15:08+00:00 2026-06-17T08:15:08+00:00

So I’m still a fledgling programmer and I would really appreciate it if someone

  • 0

So I’m still a fledgling programmer and I would really appreciate it if someone could explain to me how exactly the code below functions.

I’m aware without some methods I didn’t list here the code will not function but what baffles me starts at line eleven : String street is given the value of a variable that isn’t indexed (to my knowledge) and yet I’m still able to return it with the value intended and not valueless s.

How is it exactly that String s and the other variables serving the same purpose don’t modify the value of the variable I end up returning?

Once again I’m thankful for any help I get on this.

public class StreetAddress {
    String street, city, state, zip;

    StreetAddress(String s1, String c, String s2, String z) {
        street = s1;
        city = c;
        state = s2;
        zip = z;
    }

    void setStreet(String s) {
        street = s;
    }

    String getStreet() {
        return street;
    }

    void setCity(String c) {
        city = c;
    }

    String getCity() {
        return city;
    }

    void setState(String s) {
        state = s;
    }

    String getState() {
        return state;
    }

    void setZIP(String z) {
        zip = z;
    }

    String getZIP() {
        return zip;
    }

    String mailingLabel() {
        return street + "\n" + city + ", " + state + " " + zip;
    }
}

The class above would receive the information below and return a formatted label.

StreetAddress add = new StreetAddress("Cheese Island", "East Hemisphere", "The Moon", "99999999");
System.out.println(add.mailingLabel());
add.setStreet("Solar Flare");
add.setCity("Corona");
add.setState("The Sun");
add.setZIP("00000000");
System.out.println(add.mailingLabel());
  • 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-17T08:15:09+00:00Added an answer on June 17, 2026 at 8:15 am

    This is a java class that describes the concept of a StreetAddress. Basically the class describes a real life object which has properties that make sense for that object. In this case you street address contains information the street, city, state, and zip.

    You can create or instantiate a new StreetAddress object like this:

    StreetAddress streetAddress = new StreetAddress("Lincoln street", "New York", "New York", "1234");
    

    This means that you now has an object that you can pass around your program that contains the address:

    Lincoln street,

    New York,

    New York 1234

    If you want to get some information out of your object you can use that getter methods. For instance if you want to grab only the street information from your object you can do this:

    String street = streetAddress.getStreet();
    

    Similarly if you want to update the street field in you StreetAddress object you can use a setter method like this:

    streetAddress.setStreet("Washington ave");
    

    Now your object will contain the street address:

    Washington ave,

    New York,

    New York 1234

    These getter and setter methods work the same way for each field in you object: street, city, state, and zip.

    The final method:

    String mailingLabel(){  return street + "\n" + city + 
          ", " + state + " " + zip; } }
    

    Allows you to return a formatted version of your object similar to the examples above. You can print this formatted version of your object to the console by doing this:

    System.out.print(streetAddress.mailLabel());
    

    In Java you use objects to describe real world concepts and in your program you can create many objects like this StreetAddress one to carry information around. Objects and their data are stored in memory while your program is running and not in a database (unless they are EJBs but forget about that for now). If you pass an object between classes it will maintain the data in it until you alter it again with getters and setters;

    Hope this helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.