我有一个布尔数组,其大小取决于随机选择的字符串的大小.
所以我有这样的事情:
boolean[] foundLetterArray = new boolean[selectedWord.length()];
Run Code Online (Sandbox Code Playgroud)
随着程序的进展,这个特定的布尔数组将被填充为数组中每个元素的真值.我只想在数组的所有元素都为真时打印一个语句.所以我试过了:
if(foundLetterArray[selectedWord.length()]==true){
System.out.println("You have reached the end");
}
Run Code Online (Sandbox Code Playgroud)
这给了我一个越界异常错误.我也尝试了contains()方法,但即使数组中的1个元素为真,也会结束循环.我是否需要一个迭代遍历数组所有元素的for循环?我该如何设置测试条件?
我有以下结构:
3桌:电影,演员,流派
电影表架构:
Schema::create('movies', function (Blueprint $t) {
$t->increments('id');
$t->string('title');
$t->integer('genre_id')->unsigned();
$t->foreign('genre_id')->references('id')->on('genres');
$t->string('genre');
$t->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
类型表架构:
Schema::create('genres', function (Blueprint $t) {
$t->increments('id');
$t->string('name');
$t->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
演员表架构:
Schema::create('actors', function (Blueprint $t) {
$t->increments('id');
$t->string('name');
$t->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
电影模态:
public function genre()
{
return $this->belongsTo('App\Genre');
}
public function actor()
{
return $this->belongsToMany('App\Actor');
}
Run Code Online (Sandbox Code Playgroud)
类型莫代尔:
public function movie()
{
return $this->hasMany('App\Movie');
}
Run Code Online (Sandbox Code Playgroud)
演员莫代尔:
public function movie()
{
return $this->belongsToMany('App\Movie');
}
Run Code Online (Sandbox Code Playgroud)
形成:
<form method="post" action="{{ route('movies.insert') }}">
<input type="text" name="movieName" id="movieName">
<input type="text" name="actorName" id="actorName"> …Run Code Online (Sandbox Code Playgroud)