1.在JAVA语句中,如果语句太长了,我想连着在第二行写,要怎么实现啊
String aa="asdfgdjkhfdsaSDFJDFG"
+ "HJKLDFHGJKDFFGHJKFDGH";
除了这个方法还想要什么漂亮的效果?
StringBuffer aa=new StringBuffer("asdfgdjkhfdsaSDFJDFG");
aa.append("HJKLDFHGJKDFFGHJKFDGH");
aa.append("HJKLDFHGJKDFFGHJKFDGH");
aa.append("HJKLDFHGJKDFFGHJKFDGH");
aa.append("HJKLDFHGJKDFFGHJKFDGH");
这样写也中。
2.在java中写一段很长的SQL语句该怎么写 我这个该怎么改
说个简单点的办法,你这个SQL语句别分行,比如你的sql语句是这样的。
select "+ uid +"from " +t_user_log +" where name = "+ name+ “and date between '”+
date +"'"
写成类似于这种的。
你这SQL语句我看着没什么问题,你扔到你数据库里看看能不能查出来。我拼SQL语句一直都是先写好SQL语句,然后把条件换成“”.双引号和括号再做处理,你这么走几遍就能看出是哪有问题了。
3.java中的让字符串跨行符号是什么
你说的意思:
.net中:
string query = @"SELECT foo, bar
FROM table
WHERE id = 42";php中
Example of string
spanning multiple lines
using nowdoc syntax.
EOD;
echo My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
EOT;
?>;这种跨行书写,不用在每句话的后面添加+
groovy:
assert '''hello,
world''' == 'hello,\nworld'
//triple-quotes for multi-line strings, adds '\n' regardless of host system
assert 'hello, \
world' == 'hello, world' //backslash joins lines within stringjava中有没有?没有
转载请注明出处育才学习网 » java一条语句太长怎么跨行写