I have a List of String like:
List<String> locations = Arrays.asList("US:5423","US:6321","CA:1326","AU:5631");
Run Code Online (Sandbox Code Playgroud)
And I want to convert in Map<String, List<String>> as like:
AU = [5631]
CA = [1326]
US = [5423, 6321]
Run Code Online (Sandbox Code Playgroud)
I have tried this code and it works but in this case, I have to create a new class GeoLocation.java.
List<String> locations=Arrays.asList("US:5423", "US:6321", "CA:1326", "AU:5631");
Map<String, List<String>> locationMap = locations
.stream()
.map(s -> new GeoLocation(s.split(":")[0], s.split(":")[1]))
.collect(
Collectors.groupingBy(GeoLocation::getCountry,
Collectors.mapping(GeoLocation::getLocation, Collectors.toList()))
);
locationMap.forEach((key, value) -> System.out.println(key + " = …Run Code Online (Sandbox Code Playgroud) 我只有一个基本问题,为什么以下陈述之间存在差异?
System.out.printf("%.2f \n", 55050000.41f);
System.out.printf("%.2f \n", 50.41f);
Run Code Online (Sandbox Code Playgroud)
输出
55050000.00
50.41
Run Code Online (Sandbox Code Playgroud)
第一条语句删除了一个十进制值,为什么不删除第二条语句?
我对 lambda 知之甚少,而且 lambda 表达式被视为一个函数。我们有很多方法可以做到这一点。
这是我在TypeScript文件中的简单功能
byPan(card1,card2){
return card1.pan == card2.pan;
}
Run Code Online (Sandbox Code Playgroud)
我在 HTML 文件中使用的,如
<select [compareWith]="byPan" class="form-control" [(ngModel)]="card">
<option *ngFor="let cardInfo of cards" [ngValue]="cardInfo">{{cardInfo.pan}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
如果我想在 lambda 中替换这个函数,那么我可以写如下。
var myFunc2 = (card1, card2) => { return card1.pan == card2.pan};
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,我可以直接在任何角度属性上使用这个 lambda 函数compareWith吗?
<select [compareWith]="(card1,card2)=> { return card1.pan == card2.pan}" class="form-control" [(ngModel)]="card">
<option *ngFor="let cardInfo of cards" [ngValue]="cardInfo">{{cardInfo.pan}}</option>
</select>
Run Code Online (Sandbox Code Playgroud) 我是 Play 框架的新手。我按照这个链接安装成功,但现在我想在 Eclipse 上集成项目。我查看了play的官方链接,但我不明白该写在哪里
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
Run Code Online (Sandbox Code Playgroud)
和其他步骤。
我正在使用 Mac Os X 和 Eclipse Luna。