如何在greet()中返回期望值 [英] How to returns the expected value in the greet()

查看:109
本文介绍了如何在greet()中返回期望值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public class Person {
  String name;

    public Person(String personName) {
            name = personName;
    }

    public String greet(String yourName) {
            return String.format("Hi %s, my name is %s", name, yourName);
    }
}

推荐答案

如评论中所述,切换String.Format中的变量。这很容易被注意到,所以我不确定你为什么不问一个问题以及为什么你会坚持这个。
As mentioned in the comments, switch the variables in your String.Format. This is very easy to notice so I am unsure why you did not ask a question and why you are stuck on this.


这篇关于如何在greet()中返回期望值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆