所以我试图使用依赖于用户输入的if-else语句.当用户的输入只有一个单词时,它可以工作,但是,多个单词输入无法识别并触发else语句.我该如何解决这个问题?
import java.util.Scanner;Run Code Online (Sandbox Code Playgroud)public class MyFirstJavaClass {
public static void main(String[] args) { @SuppressWarnings("resource") Scanner myScanner = new Scanner(System.in); String answer; System.out.println("Catch the tiger or run away?"); answer = myScanner.next(); if (answer.equals("Catch the tiger" )) { System.out.println("You've been mauled by a tiger! What were you thinking?"); answer = myScanner.next(); } else { System.out.println("run away"); } } }
int[] high = {2,3,4,5,6};
Run Code Online (Sandbox Code Playgroud)
数组是否可以给出-1的恒定值?清除{2,3,4,5,6}都等于-1.
确定活动1在gridVideoView中显示来自SD卡的视频缩略图.我希望能够点击并将数据传递到活动2并播放这些视频.我买的这本书只告诉我如何用字符串做这个.我怎么能这样做,所以当我点击活动1中的视频时,它会被传递并可以在活动2中播放?如果你想要我会发布的代码.
Intent intent = new Intent(getBaseContext(), Editor.class);
intent.putExtra("mnt/sdcard-ext", _ID);
startActivity(intent);
private VideoView video;
private MediaController ctlr;
File clip=new File(Environment.getExternalStorageDirectory(),
"mnt/sdcard-ext");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr=new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我如何在VideoView中引用意图?