假设我们有一个简单的方法,它应该连接Person集合的所有名称并返回结果字符串.
public String concantAndReturnNames(final Collection<Person> persons) {
String result = "";
for (Person person : persons) {
result += person.getName();
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法用1行的新流API forEach函数编写这段代码?
我想在我的角度模板中做一个if-else语句.我从那开始:
<ng-container *ngIf="contributeur.deb; else newDeb" >
[... HERE IS A RESULT 1]
</ng-container>
<ng-template #newDeb>
[... HERE IS A RESULT 2]
</ng-template>
Run Code Online (Sandbox Code Playgroud)
我试图只使用ng-container:
<ng-container *ngIf="contributeur.deb; else newDeb" >
[... HERE IS A RESULT 1]
</ng-container>
<ng-container #newDeb>
[... HERE IS A RESULT 2]
</ng-container >
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用.我有这个错误:
ERROR TypeError: templateRef.createEmbeddedView is not a function
at ViewContainerRef_.createEmbeddedView (eval at <anonymous> (vendor.bundle.js:11), <anonymous>:10200:52)
at NgIf._updateView (eval at <anonymous> (vendor.bundle.js:96), <anonymous>:2013:45)
at NgIf.set [as ngIfElse] (eval at <anonymous> (vendor.bundle.js:96), <anonymous>:1988:18)
at updateProp (eval at …Run Code Online (Sandbox Code Playgroud) 我目前正在做正式的playframework教程:https://www.playframework.com/documentation/2.3.x/Tutorials .本教程建议使用Typesafe的激活工具.我不明白为什么在创建新项目时我会获得另一个激活器文件.
当我使用以下命令行创建项目时:
activator new test-app play-java
Run Code Online (Sandbox Code Playgroud)
我的终端显示:
Fetching the latest list of templates...
OK, application "test-app" is being created using the "play-java" template.
To run "test-app" from the command line, "cd test-app" then:
/Users/XXXXX/Documents/Developpements/play-sandbox/test-app/activator run
To run the test for "test-app" from the command line, "cd test-app" then:
/Users/XXXXX/Documents/Developpements/play-sandbox/test-app/activator test
To run the Activator UI for "test-app" from the command line, "cd test-app" then:
/Users/XXXXX/Documents/Developpements/play-sandbox/test-app/activator ui
Run Code Online (Sandbox Code Playgroud)
我可以在test-app目录中观察到这一点:
442 1 oct 01:01 .
238 1 oct 01:01 .. …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习序列化如何与Java及其最新版本一起使用.我正在尝试序列化这样的lambda:
Runnable r = (Runnable & Serializable)() -> {System.out.println("This is a test");};
Run Code Online (Sandbox Code Playgroud)
但我注意到我没有关于缺少serialVersionUID变量的警告.这是正常的吗?
我知道它将在运行时生成,但强烈建议您定义它:https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html
如果可序列化类未显式声明serialVersionUID,则序列化运行时将基于类的各个方面计算该类的默认serialVersionUID值,如Java(TM)对象序列化规范中所述.但是,强烈建议所有可序列化类显式声明serialVersionUID值,因为默认的serialVersionUID计算对类细节高度敏感,这些细节可能因编译器实现而异,因此在反序列化期间可能导致意外的InvalidClassExceptions.因此,为了保证跨不同java编译器实现的一致的serialVersionUID值,可序列化类必须声明显式的serialVersionUID值.强烈建议显式serialVersionUID声明尽可能使用private修饰符,因为此类声明仅适用于立即声明的类 - serialVersionUID字段作为继承成员无用.数组类不能声明显式的serialVersionUID,因此它们始终具有默认的计算值,但是对于数组类,不需要匹配serialVersionUID值.
我该怎么办 ?如何在Lambda中定义它?
谢谢
我使用 nuxt.js + vue.js。我需要创建路由器区分大小写。我发现以下属性:caseSensitive。我\xe2\x80\x99m 尝试将其放入 nuxt.config 但它\xe2\x80\x99t 不起作用,可以通过大写的链接进行转换。如果我直接更改文件 ~project/.nuxt/router.js,一切正常。帮我弄清楚。
\n\n router: {\n extendRoutes (routes) {\n for (let key in routes) {\n routes[key]['caseSensitive'] = true\n }\n }\nRun Code Online (Sandbox Code Playgroud)\n 我目前在使用 IntelliJ 时遇到问题。我在我的项目中使用 Kotlin。我删除了一个文件(比如 test.kt),现在,我想创建一个同名的新文件。IntelliJ 无法识别 kotlin 语法并将其显示为文本文件。
删除后,我取消选中“安全删除”和“在评论和字符串中搜索”
任何人都可以帮我解决这个问题吗?
编辑:我试图删除 .idea 和 .iml 文件,重新启动 intelliJ。它不会改变任何东西。
我目前想用ngrx/effects测试我的效果.我跟着降价,但是当我想要运行我的测试时我有一个错误.
Cannot find module 'rxjs/testing' from 'jasmine-marbles.umd.js'
Run Code Online (Sandbox Code Playgroud)
这是我的代码(目前我没有做到期望,我只想要我的测试运行):
import { TestBed } from '@angular/core/testing'
import { provideMockActions } from '@ngrx/effects/testing'
import { ReplaySubject } from 'rxjs/ReplaySubject'
import { hot, cold } from 'jasmine-marbles'
import { Observable } from 'rxjs/Observable'
import { VersionService } from '../../service/version/version.service'
import { DataEffects } from './data.effect'
import { RequestVersions, ReceiveVersions } from './data.action'
describe('My Effects', () => {
let versionService: VersionService
let effects: DataEffects
let actions: Observable<any>
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
// any …Run Code Online (Sandbox Code Playgroud) 如何使用路由和文件夹结构在 URL 中传递多个可选参数?我应该创建什么文件夹结构来处理路由类似的情况
user/:id/:product
user/:id/product/:id
Run Code Online (Sandbox Code Playgroud) java ×2
java-8 ×2
nuxt.js ×2
vue.js ×2
angular ×1
if-statement ×1
java-stream ×1
javascript ×1
jest ×1
kotlin ×1
lambda ×1
marble ×1
ngrx-effects ×1
rxjs ×1
vue-router ×1