所以,我正在尝试创建一些只包含字母的kinderCode(String).如果它确实包含不是字母的字符,则需要让用户为kinderCode提供一个新值,然后再次检查该值.这里的问题是永远不会留下while循环.条件总是返回false.
kinderCode = input.next();
while (!(kinderCode.equals("[a-zA-Z]+"))) {
System.out.println("Foute ingave! Kindercode?");
kinderCode = input.next();
}
Run Code Online (Sandbox Code Playgroud) 我在java中创建了一个列表如下:
1 bbbb london
1.1 aaaa nyc
1.10 cccc jaipur
...
1.2 test test
1.11 test1 test1
Run Code Online (Sandbox Code Playgroud)
我需要根据索引 1,1.1,1.2 等对其进行排序!这些是字符串值。
喜欢:
1 bbbb london
1.1 aaaa nyc
1.2 test test
...
1.10 cccc jaipur
1.11 test1 test1
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
最初索引是浮动的,但为了在列表中获得 1.10,我将索引更改为字符串,因此Collection.sort(list)没有按预期提供输出。
我的目的是想创建一个编号的项目符号
1 Helo
1.1 helo1
1.2 helo2
1.3 hello3
2 Test
2.1 Test1
2.2 Test2
3 World
Run Code Online (Sandbox Code Playgroud)
请问有什么帮助吗?
如何检查一年中的月份是否为1月,它将查看数据库表,如果有12月(12)和年/去年,它将插入到该表中,如果没有
示例在这里,但它不起作用
SimpleDateFormat king = new SimpleDateFormat("MM");
String M = (king.format(new java.util.Date()));
String L = M;
if (L.equals(1)) {
// then it will check the database table if there is none
// if the rs.next is false then it will count and insert the last
// month and last year patient
} else() {
// if it is not Month of January then it will insert the last month this work
// for me but the other is not
} …Run Code Online (Sandbox Code Playgroud) 我是java编程的新手,我正在尝试使用Arrays.sort()函数对数组进行排序.使用Arrays.sort(数组)后,我打印最终排序的数组.
例如:
输入:1 3 2 4
输出如下: 0 0 0 0.
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
public class TestClass {
public static final int MAX_SIZE = 20;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n,temp,count;
int[] array = new int[MAX_SIZE];
n = input.nextInt();
for(int i = 0 ; i < n ; ++i) {
array[i] = input.nextInt();
}
Arrays.sort(array);
for(int i = 0 ; i < …Run Code Online (Sandbox Code Playgroud) 我已将我的应用程序转移到另一台笔记本电脑上,并在控制台中收到此错误。知道为什么会发生这种情况吗?
未捕获的ReferenceError:进程未在对象.../../node_modules/@babel/types/lib/definitions/core.js (vendor.js:133069)在webpack_require (runtime.js:85)在对象.. ./../node_modules/@babel/types/lib/definitions/index.js (vendor.js:135192) 在 webpack_require (runtime.js:85) 在 Object.../../node_modules/@babel/types /lib/builders/builder.js (vendor.js:130507) 在 webpack_require (runtime.js:85) 在 Object.../../node_modules/@babel/types/lib/builders/ generated/index.js ( vendor.js:130871) 在 webpack_require (runtime.js:85) 在 Object.../../node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js (vendor.js:137453) 在 webpack_require (运行时.js:85)
试图打印这种模式
*
***
*****
*******
Run Code Online (Sandbox Code Playgroud)
for和while循环在某种程度上不能以正确的方式工作.这个逻辑有什么问题吗?
public class Test {
public static void main(String args[]) {
for (int i = 1; i >= 4; i++) {
for (int j = 1; j <= 7; j++) {
while (i + j >= 5 && (Math.abs(j - i)) <= 3) {
System.out.print("*");
}
System.out.print(" ");
}
System.out.println();
}
}
Run Code Online (Sandbox Code Playgroud) 我是一名新的java程序员.我正在写一个关于餐厅菜单的程序,但我的价格没有正确计算.每次给它0.0,应该是11.0
public class Main {
public static double priceBreadrollType;
public static double priceMeat;
public static double totalPrice;
public static void main(String[] args) {
setTotalPrice();
}
public static void priceBread (){
priceBreadrollType = 1;
}
public static void priceMeat(){
priceMeat = 10;
}
public static void setTotalPrice(){
totalPrice = priceBreadrollType + priceMeat;
System.out.println("The total prize " + totalPrice);
}
}
Run Code Online (Sandbox Code Playgroud)