我试图理解Java中的多维数组,但我认为它适用于任何语言.请考虑我在网上找到的这个代码段:
//************************************
// static array initialization
//************************************
byte[][] smallArray = { { 10, 11, 12, 13 },
{ 20, 21, 22, 23 },
{ 30, 31, 32, 33 },
{ 40, 41, 42, 43 }, };
// Display the array element at row 2, column 3
System.out.println(smallArray[1][2]);
// Value is 21
Run Code Online (Sandbox Code Playgroud)
为什么是21?我以为会是22岁.
我查了一下,因为我试图弄清楚在这种情况下长度意味着什么:
public class Pieces {
int thePieces[][][];
public Pieces(){
}
public int[][][] createPieces(){
/* pieces in order below
**** [0]
**
**
*
****
*
****
***
* …Run Code Online (Sandbox Code Playgroud) 我有一个我在ksh中使用的自定义.profile,下面是我创建的一个函数,可以从具有过于复杂或长名称的目录中来回跳过.
如您所见,路径名存储在数组(BOOKMARKS[])中以跟踪它们并在以后引用它们.我希望能够使用case语句(或必要时的OPTARG)从数组中删除某些值,这样我只需键入bmk -d #即可删除相关索引处的路径.
我已经摆弄了array +A and -A,但它刚刚搞砸了我的阵列(注释掉的代码中剩下的东西可能不太漂亮......我没有校对它).
有关如何创建该功能的任何建议/提示?谢谢!
# To bookmark the current directory you are in for easy navigation back and forth from multiple non-aliased directories
# Use like 'bmk' (sets the current directory to a bookmark number) to go back to this directory, i.e. type 'bmk 3' (for the 3rd)
# To find out what directories are linked to which numbers, type 'bmk -l' (lowercase L)
# For every new directory …Run Code Online (Sandbox Code Playgroud) 我的文档中有2个复选框数组.一个是engines[]一个是searchId[].
$("input:checkbox[@name='searchId[]']:checked").each(function() i use this to capture all the values from the searchId[] checkboxes (only if checked).
$("input:checkbox[@name='engines[]']:checked").each(function() same thing for engines
Run Code Online (Sandbox Code Playgroud)
问题是选择器获取文档中所有选中的复选框,无论其名称如何.我怎样才能让它只获得我希望获得的数组?
一些代码可以更好地理解:
$("#startSearch").live("click", function(event){
//event.preventDefault();
$("input:checkbox[@name='searchId']:checked").each(function(){
$.getJSON("startsearch.php",{searchId: $(this).val()},function(data){
alert($(this).val());
$('#status_' + $(this).val()).text(data.status);
$('#results_' + $(this).val()).text(data.results);
$('#date_' + $(this).val()).text(data.date);
$('#totalResults_' + $(this).val()).text(data.totalResults);
});
});
});
$("#submit").click(function(event){
event.preventDefault();
$("input[@name='engines[]']:checked").each(function(){
$.getJSON( "addsearch.php", { inputString: $('#inputString').val(),searchString: $('#searchString').val(), engine: $(this).val() }, function(data){
//$('#searchTable tbody tr:first').empty();
var row = '<tr><td><span id ="status_'+data.id+'">'+data.status+'</span></td>'+
'<td>'+data.search+'</td>'+
'<td>'+data.category+'</td>'+
'<td>'+data.engine+'</td>'+
'<td><span id = "results_"'+data.id+'">0</span></td>'+
'<td><span …Run Code Online (Sandbox Code Playgroud) 我刚刚被烧毁,因为我find_index在我的开发盒上使用了一个数组(使用Ruby 1.8.7的OSX),部署机器运行Ruby 1.8.6.(find_index和之间有什么区别index?后者适用于1.8.7和1.8.6)
这让我想到:强制Rails运行特定Ruby版本的最佳方法是什么?
因为它可能是相关的(安装多个rubys!),我需要知道这对于OSX,但是知道Linux,Windows和Commodore 64也是有用的.
后来:当然我现在正在使用虚拟设备,但我希望能够在我的计算机上控制我的Ruby版本.
注意:我不太在意不允许Rails运行错误的Ruby版本.我更感兴趣的是运行RIGHT ruby版本.对困惑感到抱歉.
我有一个名为'bandsplusrating'的表和一个名为'rating'的表.'bandsplusrating'表填充了乐队,表'rating'开始为空.
两个表都有一个名为'naam'的字段,可以将它们连接起来.表'评级'有一个名为'fullname'的字段
每个频段的多个评级(bandsplusrating)将存储在表'评级'中
现在我想显示来自'bandsplusrating'的所有记录,这些记录没有被给定用户评级(ratings.fullname)
SELECT b.naam, b.stijl
FROM bandsplusrating b
LEFT JOIN ratings r ON b.naam = r.naam
WHERE r.fullname NOT LIKE 'Obama'
Run Code Online (Sandbox Code Playgroud)
当其他用户对其进行评级时,此查询仍会显示记录.
我现在已经好几天了,有人能协助我吗?
谢谢!
我有一个使用automake和autoconf的C++项目.我是这两个人的新手.
我的主目录是网络安装的 - 我们拥有的每台服务器都是一样的 - 我想在不同的机器上同时编译和运行项目(及其可执行文件).
我们的服务器通常是不同的架构.我的桌面是32位,但服务器是64位等.
哪些选项我在使用configure.ac和Makefile.am编写命名为计算机体系结构不同的目录中的目标文件?在常规Makefile中执行此操作相对简单,但我不知道如何设置autotools.
我以为自己在iPhone开发方面经验丰富,但是我在第一个视频上踩着斯坦福iPhone课程.
(38分钟)
老师将NSObject拖入MainWindow.xib.当他在Identity Inspector(Cmd-4)中检查Object时,会有Class Actions和Class Outlets部分.
但是,这些并不适合我,只有Class Identity和Interface Builder Identity ......它们在哪里?
我想知道我如何能够使用外键来执行搜索
class Product(models.Model):
name = models.CharField(max_length = 127)
description = models.TextField()
code = models.CharField(max_length = 127)
def __unicode__(self):
return self.name + " - " + self.code
class ProductLot(models.Model):
product = models.ForeignKey(Product)
code = models.CharField(max_length = 30)
lot_no = models.CharField(max_length = 30)
location = models.CharField(max_length = 127)
incoming = models.IntegerField()
commited = models.IntegerField()
available = models.IntegerField()
reorder = models.IntegerField()
created_date = models.DateField(auto_now_add=True)
def __unicode__(self):
return self.code + " - " + self.product.name + " - " + self.lot_no
class LotComment(models.Model):
product_lot …Run Code Online (Sandbox Code Playgroud) 有没有人知道是否可以在UIWebView中为特定的HTML元素禁用电话号码,电子邮件地址等数据检测器?
我希望探测器对于加载到UIWebView中的大多数内容都是活动的,但在某些区域禁用它.
如果这是可能的,我假设它将通过在加载的内容中使用HTML属性来实现(而不是设置某种UIWebView属性),例如
<html>
<body>
<h1 datadetectors="off">Header text with number 9123 3456</h1>
<p>Body text with number 9872 4567</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在此示例中,由于设置webview.dataDetectorTypes = UIDataDetectorTypeAll,<p>中的数字将被检测为电话号码,而<h1>中的数字则不会.
(这不是一个问题本身,我正在记录我使用Ext JS 3.1.0找到的解决方案.但是,如果你知道更好的解决方案,请随时回答!)
Ext JS Grid对象的Column配置没有允许自动换行文本的本机方式,但是有一个css属性可以覆盖TD网格创建的元素的内联CSS .
不幸的是,TD元素包含一个DIV包裹内容元素,并DIV设置为white-space:nowrap通过的Ext JS的样式,所以重写TDCSS没有好处.
我将以下内容添加到我的主CSS文件中,这是一个简单的修复程序,似乎不会破坏任何网格功能,但允许white-space我应用于TD的任何设置都传递给DIV.
.x-grid3-cell {
/* TD is defaulted to word-wrap. Turn it off so
it can be turned on for specific columns. */
white-space:nowrap;
}
.x-grid3-cell-inner {
/* Inherit DIV's white-space from TD parent, since
DIV's inline style is not accessible in the column
definition. */
white-space:inherit;
}
Run Code Online (Sandbox Code Playgroud)
YMMV,但它对我有用,想要把它作为一个解决方案,因为我找不到通过搜索Interwebs的工作解决方案.