我似乎无法理解这个特定的算法.它似乎是一种bubblesort但不是传统意义上的.它是什么?
public static void main(String[] args)
{
double[] a = {0.75, 0.5, 1.0};
sort(a);
for (int i = 0; i < a.length; i++)
System.out.println(a[i]);
}
public static void sort(double[] tal)
{
double p = 0;
int k = 0;
for (int i = 0; i < tal.length - 1; i++)
{
k = i;
for (int j = i + 1; j < tal.length; j++)
{
if (tal[j] < tal[k])
k = j;
}
p = tal[i];
tal[i] …Run Code Online (Sandbox Code Playgroud) 为了试验@SuppressWarnings注释,我编写了以下示例程序:
public class Test {
public static void main(String[] args) {
@SuppressWarnings("unchecked")
Set set = new HashSet();
Integer obj = new Integer(100);
set.add(obj);
}
}
Run Code Online (Sandbox Code Playgroud)
但即使在这个注释之后,我在控制台上得到以下输出:
Note: Test.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)
如果我在main方法声明之前移动注释,则会禁止警告.这里缺少什么?
谢谢.
我在下一行使用了毕加索:
ImageView im = (ImageView)findViewById(R.id.picassotest);
Picasso.with(this).setLoggingEnabled(true);
Picasso.with(this).load("http://lacuadramagazine.com/wp-content/uploads/sangeh-monkey-forest-101.jpg").into(im);
Run Code Online (Sandbox Code Playgroud)
但是当我运行应用程序时没有任何显示.我已经添加了INTERNET许可,但仍然没有任何反应.我从中获得的唯一日志记录是:
12-01 17:28:49.460 7453-7453/? D/Picasso: Main created [R0] Request{http://lacuadramagazine.com/wp-content/uploads/sangeh-monkey-forest-101.jpg}
12-01 17:28:49.463 7453-7472/? D/Picasso: Dispatcher enqueued [R0]+5ms
12-01 17:28:49.464 7453-7474/? D/Picasso: Hunter executing [R0]+6ms
12-01 17:28:49.476 7453-7472/? D/Picasso: Dispatcher batched [R0]+18ms for error
12-01 17:28:49.479 7453-7453/? D/: HostConnection::get() New Host Connection established 0xb42d6b00, tid 7453
12-01 17:28:49.701 7453-7472/? D/Picasso: Dispatcher delivered [R0]+243ms
12-01 17:28:50.265 7453-7453/? D/Picasso: Main errored [R0]+807ms
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我是java的新手,我的代码有问题.我试图从子类的构造函数中调用超类的构造函数.虽然我可以通过super来做,但我试图通过制作超类的对象来做其他方法子类的将要调用的构造函数Class A constructor.
class A
{
private int x;
A()
{
System.out.println("INISDE A");
}
A(int h)
{
System.out.println("a");
x = h;
}
}
class B extends A
{
int g, add;
B(int j, int h)
{
A a = new A(h);
g = j;
add = g + h;
}
void add()
{
System.out.println("SUM" + add);
}
}
public class Ja
{
public static void main(String[] args) {
// TODO code application logic here
B v …Run Code Online (Sandbox Code Playgroud) 最近,在运行我们的应用程序时,我们遇到了内存不足异常.
这是异常发生之前的堆转储
Heap
def new generation total 1572864K, used 366283K [0x00000006b0000000, 0x000000071aaa0000, 0x000000071aaa0000)
eden space 1398144K, 13% used [0x00000006b0000000, 0x00000006bbb12d40, 0x0000000705560000)
from space 174720K, 100% used [0x0000000710000000, 0x000000071aaa0000, 0x000000071aaa0000)
to space 174720K, 0% used [0x0000000705560000, 0x0000000705560000, 0x0000000710000000)
tenured generation total 3495296K, used 2658714K [0x000000071aaa0000, 0x00000007f0000000, 0x00000007f0000000)
the space 3495296K, 76% used [0x000000071aaa0000, 0x00000007bcf06ba8, 0x00000007bcf06c00, 0x00000007f0000000)
compacting perm gen total 42048K, used 41778K [0x00000007f0000000, 0x00000007f2910000, 0x0000000800000000)
the space 42048K, 99% used [0x00000007f0000000, 0x00000007f28ccb80, 0x00000007f28ccc00, 0x00000007f2910000)
No shared spaces configured.
Run Code Online (Sandbox Code Playgroud)
看起来老几乎已经满了(76%).我假设当它最终达到100%OOM发生时.然而,看起来伊甸园只有13%.
有人可以解释为什么OOM会发生,即使年轻人还有一些空间吗?