9

JAVA分享篇(25)基础知识大总结

 1 year ago
source link: https://www.laiketui.com/102068.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

JAVA分享篇(25)基础知识大总结

行业动态 2023年1月5日 17:36 10

代码如下:

实体类
package cn.itsource.domain;

import lombok.AllArgsConstructor;

import lombok.Data;

import lombok.NoArgsConstructor;

/**
* @author : pankun
* @Version : 1.0
**/

@Data

@NoArgsConstructor

@AllArgsConstructor

public class ShopInfo {

/**
* 商品名称
*/

private String name;

/**
* 商品价格
*/

private String price;

/**
* 商品产地
*/

private String address;

服务接口
package cn.itsource.provider;

/**
* @author : pankun
* @Version : 1.0
**/
public interface ShopService {

String getShopInfoById(int a);

}
服务实现类
package cn.itsource.provider;

import cn.itsource.domain.ShopInfo;

import java.util.HashMap;

/**
* @author : pankun
* @Version : 1.0
*
**/
public class ShopServiceImpl implements ShopService {
private static HashMap<Integer, ShopInfo> map = new HashMap<Integer, ShopInfo>();

static {
map.put(1, new ShopInfo(“苹果”, “5”,”四川”));
map.put(2, new ShopInfo(“香蕉”, “6”,”海南”));
map.put(3, new ShopInfo(“芒果”, “8”,”云南”));
}

@Override
public String getShopInfoById(int a) {
return map.get(a).toString();
}
}
免责声明:部分文章信息来源于网络以及客户意见反馈,本站只负责对文章进行整理、排版、编辑,出于传递更多信息之目的,并不意味着赞同其观点或证实其内容的真实性,如本站文章和转稿涉及版权等问题,请作者在及时联系本站,我们会尽快联系您处理


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK