我有号码
1110000010
Run Code Online (Sandbox Code Playgroud)
需要格式化,以便在前3个字符后面插入一个空格,在另外3个字符后插入另一个空格,使其看起来像:
111 000 0010
Run Code Online (Sandbox Code Playgroud)
什么是简单的java正则表达式模式来实现这一目标?
我有表的用户user_id,user_name和user_dob.
我想算一下18岁以下,18-50岁以上和50岁以下的用户数量.
需要改进Age计算方法来计算确切的年龄,但是现在我更感兴趣的是找到计算方法
所以我尝试过:
SELECT COUNT ([user_id])
from [user]
where (DATEDIFF(yy,[user_dob], GETDATE()) < 18)
UNION ALL
SELECT COUNT ([user_id])
from [user]
where (DATEDIFF(yy,[user_dob], GETDATE()) >= 18 AND DATEDIFF(yy,[user_dob], GETDATE()) <=50)
UNION ALL
SELECT COUNT ([user_id])
from [user]
where (DATEDIFF(yy,[user_dob], GETDATE()) > 50)
Run Code Online (Sandbox Code Playgroud)
它给我的结果如下:
(No column name)
1218
3441
1540
Run Code Online (Sandbox Code Playgroud)
但我需要这样的东西
Range | Count
----------------
Under 18 | 1218
18-50 | 3441
Over 50 | 1540
Run Code Online (Sandbox Code Playgroud)
有关如何存档以上格式的任何建议?
我正在尝试获取韩语单词 (a String)的最后一个字符,但它没有按计划工作。如果我有字符串:"??",我想得到 ,"?"但我得到了"?"。
我已经尝试过的:
word.charAt(word.length-1); // gets ?
Run Code Online (Sandbox Code Playgroud)
我还检查了是否"??"以"?"using结尾word.endsWith("?"),但它返回 false。
如果我问,它会给出真实的回报,word.endsWith("?")。
我有一个启动画面,如果服务器上有任何新内容,则会检查URL.如果show我希望向app用户显示一个AlertDialog,以便取决于用户的操作,即如果YES从服务器下载新内容并将其送到数据库,否则如果NO从服务器加载应用程序的内容.
但是,我无法在AsyncTask中使用警报对话框我的代码段如下:
protected String doInBackground(String... mode){
/* I AM QUERY MY DATABASE FOR THE PREVIOUS CONTENT(SAY CONTENT 1, CONTENT 2);
* then i start my connection to the server which has an xml file with the content
* info (say content 3), at this stage .
* i Check certain condition here,
* say if result ==0 then i wish to display an alertdialog.
* I used an alert dialog and i get some error. Stating use Looper or Handler. …Run Code Online (Sandbox Code Playgroud) 在静态方法覆盖的情况下..我已经开发了以下代码
class Ab {
static void getF() {
System.out.println("I am saral");
}
}
class Ham extends Ab {
static void getF() {
System.out.println("I am saral saxena");
}
public static void main(String[] args) {
// Ham h = new Ham();
// h.getF(); //Ham
Ab a = new Ham();
a.getF(); // Ab class
}
}
Run Code Online (Sandbox Code Playgroud)
现在我的查询是,当我使用多态行为时,Ab a = new Ham();在静态方法覆盖的情况下,在这个阶段我仍然得到getF();类的方法Ab,请指教.
修改外类字段的正确方法是什么?当尝试从内部静态类更改时value,Artifact它会产生错误.需要迭代包含类型对象的数组列表Artifact; 并且能够为每个Artifact(无论是硬币还是高脚杯)显示该值.
public class Artifact {
public int value = 0;
public static class Goblet extends Artifact{
value = 5; // Syntax error on token "value", VariableDeclaratorId expected after this token
}
public static class Coin extends Artifact{
value = 10;
}
}
Run Code Online (Sandbox Code Playgroud) 我想在这两个表之间建立关系,我创建了两个表emp和dept,如下所示,
create table emp (
empno number(4) constraint empnopk primary key,
ename varchar(10) constraint enamenn not null,
mgrno number(4) constraint mgrnofk references emp(empno),
sal number(10) constraint salck check(sal between 2000 and 5000),
age number(2) constraint ageck check(age>20),
mobno number(10) constraint mobuq unique
);
create table dept (
deptno number(10) constraint deptnopk primary key,
dname varchar(10) constraint dnamenn not null,
loc varchar(10) default 'xyz'
);
Run Code Online (Sandbox Code Playgroud)
因为emp表是主表而dept表是子表,为了使这两个表之间的关系我给出了查询
alter table emp
add constraint deptnofk foreign key(deptno) references dept(deptno);
Run Code Online (Sandbox Code Playgroud)
当我给出这个查询它显示ORA-00904:"DEPTNO":无效的标识符
可能是什么问题?
Callable接口中泛型有什么用?
考虑一下我从https://blogs.oracle.com/CoreJavaTechTips/entry/get_netbeans_6复制的以下代码:
import java.util.\*;
import java.util.concurrent.\*;
public class CallableExample {
public static class WordLengthCallable
implements Callable {
private String word;
public WordLengthCallable(String word) {
this.word = word;
}
public Integer call() {
return Integer.valueOf(word.length());
}
}
public static void main(String args[]) throws Exception {
ExecutorService pool = Executors.newFixedThreadPool(3);
Set<Future<Integer>> set = new HashSet<Future<Integer>>();
for (String word: args) {
Callable<Integer> callable = new WordLengthCallable(word);
Future<Integer> future = pool.submit(callable);
set.add(future);
}
int sum = 0;
for (Future<Integer> future : set) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用正则表达式测试字符串是否以 Java 中的点后的两位数结尾。怎样才能做到这一点?
像“500.23”这样的东西应该返回真,而“50.3”或“50”应该返回假。
我尝试过类似的事情,"500.00".matches("/^[0-9]{2}$/")但它返回 false。
我正在尝试从两个表中提取数据,这些表计算每个客户端的订单数量.下面的SQL在没有输入S.Name的情况下工作正常SELECT,但我希望输出中的客户端名称比其StoreID更有意义.当我添加S.Name时,我收到以下错误:
列'uStores.Name'在选择列表中无效,因为它不包含在聚合函数或GROUP BY子句中.
SELECT O.StoreID, COUNT(O.StoreID) AS OrderCount, S.Name
FROM Orders AS O
JOIN Stores AS ON O.StoreID = S.StoreID
GROUP BY O.StoreID
ORDER BY OrderCount DESC
Run Code Online (Sandbox Code Playgroud)
如何使此查询有效?
java ×6
sql ×3
regex ×2
sql-server ×2
string ×2
android ×1
callable ×1
concurrency ×1
exception ×1
generics ×1
looper ×1
oop ×1
oracle11g ×1
overriding ×1