我的Android应用程序中有一个文件列表,我希望能够获取所选项目并通过电子邮件或任何其他共享应用程序发送.这是我的代码.
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_EMAIL, getListView().getCheckedItemIds());
sendIntent.setType("text/plain");
startActivity(sendIntent);
Run Code Online (Sandbox Code Playgroud) 我想在ruby中生成一个64位整数.我在Java中知道你有很多,但我不确定你会如何在Ruby中做到这一点.另外,64位数中有多少个字符?这是我所说的一个例子...... 123456789999.
@num = Random.rand(9000) + Random.rand(9000) + Random.rand(9000)
Run Code Online (Sandbox Code Playgroud)
但我相信这是非常低效的,必须有一个更简单,更简洁的方法.
谢谢!
我有一个关于使用memoization(DP)实现Fibonacci序列的快速问题.我正在使用HashTable,但由于某种原因,该表似乎永远不会包含这些元素.我插入一个print语句,以便在从哈希表中读取值时打印出来,似乎这种情况从未发生过.我觉得这是一个简单的修复,但我没有看到它.
public static int getFib(int n) {
HashMap<Integer, Integer> dictionary = new HashMap<Integer, Integer>();
if (n <= 2)
return 1;
else if (dictionary.containsKey(n)) {
System.out.println("Reading From Table");
return dictionary.get(n);
} else {
int val = getFib(n - 1) + getFib(n - 2);
dictionary.put(n, val);
return val;
}
}
Run Code Online (Sandbox Code Playgroud) 我试图拆分created_at方法返回的值.
我正在获取一个object(item)并获得它创建的时间.我不想要整个结果,我只对日,月和年感兴趣.我怎样才能让它发挥作用?
<% @items_in_basket.each do |item| %>
<% splliter = item.created_at.split(" ") %>
<% time = @splliter[0] %>
Run Code Online (Sandbox Code Playgroud)
我得到了这个结果:
undefined method 'split' for Wed, 31 Jul 2013 16:44:37 UTC +00:00:Time
Run Code Online (Sandbox Code Playgroud)