可以在此处找到Dalvik的源代码,虚拟机相关代码位于名为的文件夹中vm.几乎所有的代码都是用C++编写的.但是,有关Dalvik的详细文档似乎在互联网上缺失.
我想在原始Dalvik上开发一些新功能,例如Thread Migration to和Thread Sync with remote servers.谁能告诉我我可以参考哪些文件以及我应该在哪里开始我的项目?
我知道你可以在像grepcode这样的地方查看Java的"源代码",但我正在寻找一些方法来查看构建在Java之上的C代码.我觉得这个问题肯定已被多次提出,但我找不到满意的答案.
这不是出于任何明确的目的 - 我只想了解编程语言如何"构建"得更好一点.
此外,如果有人可以展示如何查看生成的字节码,这可能也会有所帮助.
我正在尝试编写一个脚本来查看一行的一部分,执行sort -u或者查找唯一的事件,然后显示输出,按行的ORIGINAL顺序排序.换句话说,只会显示该行的第一次出现.
我设法使用cut,但我的输出只显示数据的切割部分.我怎么能这样做才能得到整条线?
这是我到目前为止所得到的:
cut -d, -f6 infile.txt | cut -c4-11 | grep -n . | sort -t: -k2,2 -u | sort -t: -k1n,1 | cut -d: -f2-
Run Code Online (Sandbox Code Playgroud)
我知道数据没有额外的:或,在一个会破坏这个脚本的地方.但这只会输出唯一的数据.我怎样才能获得整条生产线?我宁愿远离perl,但是awk还可以(虽然我不太清楚).
如果输入文件是这样的(注意,ABCDEFGH不是真的,我只是把它放在那里来说明我的意思):
A....,....,...........,.....,....,...20130718......,.........,...........,......
B....,....,...........,.....,....,...20130714......,.........,...........,......
C....,....,...........,.....,....,...20130718......,.........,...........,......
D....,....,...........,.....,....,...20130719......,.........,...........,......
E....,....,...........,.....,....,...20130713......,.........,...........,......
F....,....,...........,.....,....,...20130714......,.........,...........,......
G....,....,...........,.....,....,...20130630......,.........,...........,......
H....,....,...........,.....,....,...20130718......,.........,...........,......
Run Code Online (Sandbox Code Playgroud)
我的课程输出:
20130718
20130714
20130719
20130713
20130630
Run Code Online (Sandbox Code Playgroud)
我想看看:
A....,....,...........,.....,....,...20130718......,.........,...........,......
B....,....,...........,.....,....,...20130714......,.........,...........,......
D....,....,...........,.....,....,...20130719......,.........,...........,......
E....,....,...........,.....,....,...20130713......,.........,...........,......
G....,....,...........,.....,....,...20130630......,.........,...........,......
Run Code Online (Sandbox Code Playgroud) 为什么这是编译错误?Java无法同时达到这两种声明bar.
import java.util.Random;
public class SwitchTest {
public static void main(String[] args) {
Random r = new Random();
int foo = r.nextInt(2);
switch(foo) {
case 0:
int bar = r.nextInt(10);
System.out.println(bar);
break;
case 1:
int bar = r.nextInt(10) + 10; // Doesn't compile!!
System.out.println(bar);
break;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试从网页中读取源代码。我的Java代码是
import java.net.*;
import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
class Testing{
public static void Connect() throws Exception{
URL url = new URL("http://excite.com/education");
URLConnection spoof = url.openConnection();
spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" );
BufferedReader in = new BufferedReader(new InputStreamReader(spoof.getInputStream()));
String strLine = "";
while ((strLine = in.readLine()) != null){
System.out.println(strLine);
}
System.out.println("End of page.");
}
public static void main(String[] args){
try{
Connect();
}catch(Exception e){
}
}
Run Code Online (Sandbox Code Playgroud)
当我编译并运行此代码时,它提供以下输出:
? I?%&/m?{J?J??t?$?@??????iG#)?*??eVe]f@????{???{???;?N'????\fdl??J??!?? ??~|?"~?$}?>???????4?????7N?????+??M?N???J?tZfM??G?j?? ??R??!?9??>JgE??Ge[????????W???????8?????? ?|8? ??????? ??ho????0????|?:--?|?L?U?????m?zt?n3??l\?w??O^f?G[?CG< ?y6K??gM?rg???y?E?y????h~????X???l=??Z?/????(?^O?UU6???? …
从REPL(Cloure 1.4.0)我试图使用source宏来显示我的函数的定义 - 但它回复'源未找到'
我可以用source在source自己喜欢这个(可以看到它使用了source-fn) -但不知道为什么它不喜欢我的defn x[] "hello"函数的定义?
user=> (source source)
(defmacro source
"Prints the source code for the given symbol, if it can find it.
This requires that the symbol resolve to a Var defined in a
namespace for which the .clj is in the classpath.
Example: (source filter)"
[n]
`(println (or (source-fn '~n) (str "Source not found"))))
nil
user=> (defn x[] "hello")
#'user/x
user=> (source x)
Source not …Run Code Online (Sandbox Code Playgroud) 当初始选择无效时,为什么这会导致我陷入无限循环?
while (true) {
System.out.print("Choice:\t");
try {
int choice = scanner.nextInt();
break;
} catch (InputMismatchException e) {
System.out.println("Invalid Input!");
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
Choice: df
Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input!
Choice: Invalid Input! …Run Code Online (Sandbox Code Playgroud) java exception infinite-loop java.util.scanner inputmismatchexception
一个组件(例如a JLabel)可以使用多个卡CardLayout吗?
目前,该组件似乎只出现在它添加到的最后一张卡片上.
如果有办法做到这一点,我应该吗?这是不好的做法吗?或者有其他选择吗?
为什么这个程序:
import java.io.*;
public class testpage
{
public static void main(String [] args)
{
pri();
}
public static int p2 (int x)
{
System.out.print("p");
return x * x + 1;
}
public static void pri ( )
{
int y = 3;
System.out.print( p2(y) + "-" + p2(y));
}
}
Run Code Online (Sandbox Code Playgroud)
输出这个:
pp10-10
Run Code Online (Sandbox Code Playgroud)
具体来说,为什么-当方法调用相同时,每一侧的输出会有所不同?
我在这里看了很多与我有关的问题,但他们都使用不同的方法来处理我必须使用的方法.我知道这是一个非常漫长的方式来找出有更简单的方法,但我只是按照说明.
为什么以下代码不起作用?该函数检查它是否是元音.然后检查输入以查看它的长度是否为1.如果为1,则调用该函数.如果它大于1,则在长度为1之前请求另一个输入.
我现在看到JS中不存在布尔值.我想这个问题现在无效!
function isVowel(x){
boolean result;
if(x == "A" || x == "E" || x == "I" || x == "O" || x == "U" ) {
result = true;
}
else{
result = false;
}
return result;
}
var input;
input = prompt("Enter a character ");
input = input.toUpperCase();
if(input.length == 1){
isVowel(input);
}
}
else{
while(input.length != 1){
prompt("Enter a character ");
if(input.length == 1){
isVowel(input);
}
}
}
alert(isVowel(input));
Run Code Online (Sandbox Code Playgroud) java ×6
awt ×1
bash ×1
bytecode ×1
c ×1
c++ ×1
cardlayout ×1
character ×1
clojure ×1
cut ×1
dalvik ×1
declaration ×1
exception ×1
javascript ×1
macros ×1
sorting ×1
swing ×1
system.out ×1