public class Cat {

public static void main(String[] args){
    System.out.println();
}
private String fullName;

public void setName(String firstName, String lastName) {
    String fullName = firstName + " " + lastName;

}
public String getName() {
    return fullName;
}
}

this is my code can someone help me

asked 30 Apr '17, 14:32

xnopino's gravatar image

xnopino
112
accept rate: 0%

edited 30 Apr '17, 14:34


In setName method you created new local variable fullName. It dies as the method end, because you don't pass it anywhere (as first, red-marked variable in lesson 1 at this level).

Think how you can change the class variable fullName, so test method getName could return actually full name.

link

answered 08 May '17, 06:04

noelo's gravatar image

noelo
102
accept rate: 0%

edited 09 May '17, 03:04

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×35

Asked: 30 Apr '17, 14:32

Seen: 535 times

Last updated: 09 May '17, 03:04