我可以使用以下代码通过单击按钮连接到另一个html页面.
<form action="where-you-want-to-go"><input type="submit"></form>
Run Code Online (Sandbox Code Playgroud)
但我有一个问题.当页面上有两个按钮时,如何使用此代码将它们重定向到两个不同的页面?或者还有其他方法吗?
class Demo {
public static void main(String args[]) {
System.out.println("Start main");
try {
//exceptional code
int x=43/0;
} catch(ArithmeticException e) {
e.printStackTrace();
} finally {
System.out.println("final code");
}
System.out.println("End main");
}
}
Run Code Online (Sandbox Code Playgroud)
我使用上面的代码来理解finally块的机制.在这种情况下,我观察到的是,即使没有该catch块,finally块也会执行并显示发生的异常.但我观察到的差异是,当不使用catch块时,不会打印"End main".我想知道finally块执行的原因,即使未使用catch子句处理异常.我想知道finally块的基本功能是什么.
class Demo{
public static void main(String args[]){
int x=3,n=5,d=0;
int ar[]=new int[3];
String name="Neno";
System.out.println("Start main");
try{
ar[x]=name.charAt(n)/d; //n=5
}catch(StringIndexOutOfBoundsException e){
System.out.println("String index Error");
}catch(RuntimeException e){
System.out.println("Any runtime Error");
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("Array index Error");
}catch(ArithmeticException e){
System.out.println("Arithmetic Error");
}
System.out.println("End main");
}
}
Run Code Online (Sandbox Code Playgroud)
我使用此代码来过滤一些异常,但代码中存在错误.它说删除的追赶条款ArrayIndexOutOfBounds和ArithmeticException.是因为错误弹出的catch-clauses的顺序?当我改变这样的顺序时......
class Demo{
public static void main(String args[]){
int x=3,n=5,d=0;
int ar[]=new int[3];
String name="Niroth";
System.out.println("Start main");
try{
ar[x]=name.charAt(n)/d; //n=5
}catch(StringIndexOutOfBoundsException e){
System.out.println("String index Error");
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("Array index Error");
}catch(ArithmeticException e){
System.out.println("Arithmetic …Run Code Online (Sandbox Code Playgroud) function hello()
{
var request = getXHR();
request.open("GET","A?value="+document.getElementById('a').value+"",true);
request.send(null);
request.onreadystatechange=function()
{
if(request.readyState==4)
{
if(request.status==200)
{
var val=request.responseText;
document.getElementById('a').value=val*10;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在ajax教程中找到了上面的代码....我不明白使用原因
request.readyState==4
request.status==200
Run Code Online (Sandbox Code Playgroud)
谁能解释我使用此代码段的原因?
String s="";
while ((strLine = br.readLine()) != null) {
s=s.concat(strLine);
Run Code Online (Sandbox Code Playgroud)
当我使用这段代码时,我从文件中得到了我期望的字符串..但是如果我使用的话
String s = null;
Run Code Online (Sandbox Code Playgroud)
我得到的是nulls字符串的结果.有人能解释一下这个原因吗?