public class Primitive {
void m(Number b, Number ... a) {} // widening, autoboxing->widening->varargs
void m(byte b, Number ... a) {} // unboxing, autoboxing->widening->varargs
public static void main(String[] args) {
Byte b = 12;
Primitive obj = new Primitive();
obj.m(b, 23);
}
}
Run Code Online (Sandbox Code Playgroud)
我已经搜索过并发现扩展优先级高于取消装箱,因此在上面的方法调用中,应该调用第一个方法,因为第二个参数对于两者都是相同的.但这不会发生.你可以解释一下吗?
假设我已将我的软件仓库映射到客户端工作区,c:/perforce/project但现在
我想同步文件c:/perforce/project/fold1/fold2夹中的所有文件.
我们怎么做呢,因为命令p4 sync只接受文件名而不是文件夹.
我试图使用没有Typeahead的Bootstrap标签输入插件.我已经包含以下文件:
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="../../tagsinput/css/bootstrap-tagsinput.css" rel="stylesheet" type="text/css">
<script src="../../tagsinput/js/bootstrap-tagsinput.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
脚本如下:
<script>
$('#tagPlaces').tagsinput({
allowDuplicates: true
});
</script>
Run Code Online (Sandbox Code Playgroud)
使用插件的JSP表单的一部分:
<div class="form-group">
<label for="tagPlaces" class="col-sm-2 control-label">Tag Places</label>
<div class="col-sm-10">
<input type="text" class="form-control" data-role="tagsinput" id="tagPlaces">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
但我无法在输入字段中看到标签.当我按下输入标签时,我的表单也会被提交.请提出我缺少的内容以及使用该插件的正确方法.
public class aman {
void m(double a , int b, int c) {
System.out.println("second");
}
void m(float a , int b, double c) {
System.out.println("first");
}
public static void main(String[] args) {
aman obj = new aman();
obj.m(23, 12, 1);
}
}
Run Code Online (Sandbox Code Playgroud)
这里,方法m()已经重载但我不理解为什么调用是不明确的,因为在第一种方法中只需要进行1次转换,而在第二种方法中,需要进行两次转换.所以,绝对应该调用第一种方法.请说明为什么没有发生这种情况或者我错过了一些规则.
我读到了:
每当需要对集合进行排序时,元素必须是相互可比的.
我写了下面的代码,它工作正常.你能否告诉我们b级和c级是如何相互比较的,以及"相互比较"的含义是什么?
import java.util.ArrayList;
import java.util.Collections;
class b implements Comparable<c> {
String str1;
b(String str1) {
this.str1 = str1;
}
public int compareTo(c object) {
return str1.compareTo(object.str1);
}
}
class c implements Comparable<b> {
String str1;
c(String str1) {
this.str1 = str1;
}
public int compareTo(b object) {
return str1.compareTo(object.str1);
}
}
public class a {
public static void main(String[] args) {
b obj1 = new b("monster");
c obj2 = new c("aman");
ArrayList list = new ArrayList();
list.add(obj1);
list.add(obj2); …Run Code Online (Sandbox Code Playgroud) 这是代码示例,我收到错误"必须被捕获或声明被抛出",但我有
已经处理了IOException.所以你能告诉我为什么错误填充.代码也
跟随句柄并声明规则.
public void rethrow() throws SQLException, IOException {
try {
couldThrowAnException();
}
catch(Exception e) {
e = new IOException();
throw e; //Error: must be caught or declare to be thrown
}
}
Run Code Online (Sandbox Code Playgroud) 我已经读过1000个位置的静态变量没有被继承.但那么这段代码如何正常工作呢?
Parent.java
public class Parent {
static String str = "Parent";
}
Run Code Online (Sandbox Code Playgroud)
Child.java
public class Child extends Parent {
public static void main(String [] args)
{
System.out.println(Child.str);
}
}
Run Code Online (Sandbox Code Playgroud)
此代码打印"父".
还可以在几个位置读取数据隐藏的概念.
Parent.java
public class Parent {
static String str = "Parent";
}
Run Code Online (Sandbox Code Playgroud)
Child.java
public class Child extends Parent {
static String str = "Child";
public static void main(String [] args)
{
System.out.println(Child.str);
}
}
Run Code Online (Sandbox Code Playgroud)
现在输出是"Child".
那么这是否意味着静态变量是继承的,但它们遵循数据隐藏的概念?
java ×5
collections ×1
comparable ×1
data-hiding ×1
exception ×1
inheritance ×1
jdk1.6 ×1
jquery ×1
overloading ×1
p4v ×1
perforce ×1
primitive ×1
static ×1
wrapper ×1