他们说这++i
更快但我不明白为什么.谁能告诉我这些运营商的汇编代码?
我有以下字符串:
"有龙纹身的女孩(LISBETH)"
我只需要在输入的末尾的括号中获取字符串.
到目前为止,我来到这里:
public static void main(String[] args) {
Pattern pattern =
Pattern.compile("\\({1}([a-zA-Z0-9]*)\\){1}");
Matcher matcher = pattern.matcher("The girl with the dragon tattoo (LISBETH)");
boolean found = false;
while (matcher.find()) {
System.out.println("I found the text " + matcher.group()
+ " starting at " + "index " + matcher.start()
+ " and ending at index " +
matcher.end());
found = true;
}
if (!found) {
System.out.println("No match found");
}
}
Run Code Online (Sandbox Code Playgroud)
但结果我得到了:(LISBETH)
.
如何摆脱这些括号?
谢谢!
我正在尝试使用kineticjs框架设计一个可用于使用块绘制形状的编辑器.到目前为止一切都很好.我可以添加矩形,更改其大小,并旋转它.但我说的只适用于最后创建的对象.我无法选择其中一个进行修改.这里是代码的html:
<style>
body {
margin: 0px;
padding: 0px;
}
canvas {
border: 1px solid #9C9898;
}
</style>
</head>
<body>
<table width="800" border="0">
<tr>
<td colspan="2" style="background-color:#eeeeee;">
</td>
</tr>
<tr>
<td style="background-color:#eeeeee;height:200px;width:400px;">
<button id="rect">Rectangle</button><br>
<button id="small">Small</button><br>
<button id="big">Big</button><br>
<button id="rotate">RotateRight</button><br>
<button id="rotate2">RotateLeft</button><br>
<button id="delete">Delete</button><br>
</td>
<td>
<div id="container"></div>
<script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.3.0-beta2.js"></script>
<script type="text/javascript" src="example_kinetic.js"></script>
</td>
</tr>
<tr>
<td colspan="2" style="background-color:#eeeeee;text-align:center;">
Copyright © ceng314animation.wordpress.com/</td>
</tr>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是js部分:
var stage = new Kinetic.Stage({
container: 'container',
width: 800,
height: 400
}); …
Run Code Online (Sandbox Code Playgroud) Java 中有不可变类型。如果将不可变对象传递给方法,则在调用该方法后它不会更改,即使它的值在该方法中发生了更改。我知道所有原语都是不可变的。并且String
也是一成不变的。
我编写了一个简单的代码来检查 Java 中的功能,并且基元的包装类似乎也是不可变的。有人能列出java中所有不可变类型吗?
我有一个像这样的字符串:
String text = number|name|url||number2|name2|url2
现在我写了一个循环
int initialiaze = 0;
for(i = initialize; i > text.length(); i++) {
//do the work
}
Run Code Online (Sandbox Code Playgroud)
在这个循环中我想提取number
到一个字符串,name
一个字符串,url
一个字符串,如果我||
做了一个动作(例如将这三个字符串插入db)如果这个动作完成,再次启动一个提取number2
,name2
并url2
进入字符串并做一个动作.
这可能吗?你能告诉我怎么样吗?我不懂.
我试图通过谷歌和SO在这里找到解决方案但是找不到......
这是唯一的问题.它只有一个答案,它已被接受,但对我不起作用......这是我的代码:
class RegistrationsController < Devise::RegistrationsController
before_filter :authenticate_user!
def new
puts "Method new was called"
super
end
end
Run Code Online (Sandbox Code Playgroud)
当我没有登录localhost:3000/sign_up
页面时,正常显示并Method new was called
打印.如果我还没有登录,我希望控制器将我重定向到sign_in页面.当然我可以在new
方法和重定向中检查它,但这不是一个好的解决方案......我确信有一种更优雅的方式.我甚至试图使用prepend_before_filter :authenticate_user!
但它也不起作用.
编辑
我在routs.rb中为这个控制器定义了路由
devise_for :users, :controllers => { :sessions => "sessions", :registrations => "registrations" }
Run Code Online (Sandbox Code Playgroud) 我有一个来自DB的字符串.字符串是这样的: -
ABC:def,ghi:jkl,hfh:fhgh,ahf:jasg
Run Code Online (Sandbox Code Playgroud)
简而言之String:String
,它重复大价值.
我需要解析此字符串以获得不作任何单词:
或,
每个字存储在ArrayList中
我可以使用分割功能(两次)来做到这一点,但我发现使用正则表达式我可以做到一次去获得arraylist ..
String strLine="category:hello,good:bye,wel:come";
Pattern titlePattern = Pattern.compile("[a-z]");
Matcher titleMatcher = titlePattern.matcher(strLine);
int i=0;
while(titleMatcher.find())
{
i=titleMatcher.start();
System.out.println(strLine.charAt(i));
}
Run Code Online (Sandbox Code Playgroud)
然而,它没有给我正确的结果..它最终给我发现匹配的索引,然后我需要追加它,这是不合逻辑和有效的,.
有没有办法......
我有一个JCombobox,我在运行时添加一些项目.其中一些很长,我的Jcombobox也长得很长.它位于带有BoxLayout(PAGE_AXIS)的JPanel容器中.我不知道如何阻止成长...
我想知道应该有一个属性overflow
,如果它是"123456789",在组合框项目中将显示为"123 ...".
编辑:
我读了你的答案,非常感谢你.但问题是我的JPanel可以调整大小,我需要让它的孩子总是填充父母.所以我无法设置首选大小,因为我的JPanel的大小可以在运行时更改.
而且由于同样的原因,我也无法设置最大大小或使用setPrototypeDisplayValue().
我试图使用其他布局(GroupLayout,BorderLayout),但结果是一样的.
如果你愿意,我可以发布代码,但我认为没有必要.如果你还需要,请告诉我.
刚尝试使用JTextArea单行而不是JCombobox.结果是一样的.当我输入时,它正在增长.
我正在尝试在本地使用 pubsub 运行 firebase 函数。
\n已配置模拟器firebase init emulators
。
firebase emulators:start --only pubsub
工作正常,我可以看到日志:
\xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n\xe2\x94\x82 Emulator \xe2\x94\x82 Host:Port \xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xbc\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xa4\n\xe2\x94\x82 Pub/Sub \xe2\x94\x82 localhost:8085 \xe2\x94\x82\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xb4\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n
Run Code Online (Sandbox Code Playgroud)\nfirebase.json 中的 pubsub 模拟器配置:
\n"pubsub": {\n "host": "localhost",\n "port": 8085\n},\n
Run Code Online (Sandbox Code Playgroud)\n导出 pubsub 处理函数:
\nexports.testPubsub = functions.pubsub.topic("test-pubsub").onPublish(async (message) => {\n console.log(`test event received by pubsub handler: ${message.json}`);\n});\n
Run Code Online (Sandbox Code Playgroud)\n我运行 firebase 函数:firebase serve --only functions
此行出现在控制台输出中:
\nfunctions[pubsub-testPubsub]: function ignored because the pubsub emulator does not exist or is …
Run Code Online (Sandbox Code Playgroud) 我有
Field f = this.getClass().getFields()[0];
Run Code Online (Sandbox Code Playgroud)
我需要知道f
的价值this
是null
或不是.有很多像getInt()
和的方法getDouble()
,但我还没有找到像Object getData()
或的方法isNull()
.有这样的方法吗?
java ×6
regex ×2
string ×2
android ×1
arraylist ×1
c++ ×1
database ×1
devise ×1
field ×1
firebase ×1
google-cloud-pubsub-emulator ×1
html5 ×1
html5-canvas ×1
immutability ×1
increment ×1
javascript ×1
jcombobox ×1
kineticjs ×1
null ×1
reflection ×1
ruby ×1
split ×1
swing ×1
types ×1