我正在尝试解决项目欧拉的第三个问题,它需要一个12数字,问题是我写的代码没有运行:(你能帮我弄清楚吗?这个错误是如此令人困惑:
Exception in thread "main" java.lang.NumberFormatException: For input string: "51475143 "
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.
import java.util.*;
import java.io.*;
import java.lang.*;
class Ex
{
public static void main (String[] args) throws IOException
{
BufferedReader br = new BufferedReader(newInputStreamReader(System.in));
int a,b,n,c;
n=Integer.parseInt(br.readLine());
for(in
File information = new File(args[0],"temp.txt");
information.createNewFile(); //shortcut for Stackoverflow
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.redirectOutput(information); //does not work on standard output eiher
processBuilder.command(
import java.util.Scanner;
import java.lang.String;
public class Test
{
public static void main(String[] args)
{
char[] sArray;
Scanner scan = new Scanner(System.in);
System.out.print("Enter a Palindrome : ");
String s = scan.nextLine();
s =
我在拆分函数时遇到了问题。我不知道它是如何工作的。
以下是我的源代码:
// Using println to print out the result
String str = " Welcome to Java Tutorial ";
str = str.trim();
String[] arr = str.split(" ");
for (String c : arr) {
System.out.println(c);
}
//Using print to print out the resu
我的代码出了问题,我想知道是否有人能帮助我。
//I'm looking from "?PARAMETER" in a text.
locatie = inhoud.indexOf("?");
inhoud = inhoud.substring(locatie);
lengte = inhoud.length();
//is this usefull to do?
inhoud = inhoud.trim();
//make string from question mark to next space
spatie = inhoud.indexOf
我想用JFreeChart制作一个片段,并使用我从XML-文件中获得的变量。
卫理公会类:
package Statistik;
import xmlModul.XmlLoader;
public class Data {
XmlLoader xml = new XmlLoader();
int deleted;
int created;
int edited;
public int getDeleted() {
return deleted;
}
public void setDeleted(int delet
在读取文件内容时获得以下错误时,我认为我的代码没有正确地将其转换为整数,以下是错误:
Exception in thread "main" java.lang.NumberFormatException: For input string: "3 "
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unkn
Scanner input = new Scanner (System.in);
String str = input.nextLine(); // reads x , y
int x = Integer.parseInt(str.substring(0, str.indexOf(","))); // this reads the numbers until comma
我有下面的代码
import java.io.*;
import java.util.*;
class MainDriver{
public static void main(String aa[]){
Scanner reader = new Scanner (System.in);
String name;
System.out.println("enter your name");
name = reader.nextLine();
name.trim();
System
当我启动tomcat9.0服务器(学校项目)时,我正试图解决这个问题,但它在web上显示了我:连接失败。
INFO: Server startup in [608] milliseconds
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.c
我正在编写一个使用JDBC从数据库(MariaDB)删除所有数据的程序,但我得到了以下错误:
Exception in thread "main" java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
我正在尝试为类创建一个程序,当用户输入系数时,该程序计算给定方程的判别式。不过,我在将输入从字符串转换为int时遇到了问题。我的老师一心想要确保我让用户在一行中输入所有的系数,这就是问题所在。 到目前为止,我的代码如下: /*
* Write a program that will determine the number and type of roots
* for a quadratic equation, given the coefficients a, b, and c.
*/
import java.util.Scanner;
public class Main
{
我已经写了下面的代码,不太清楚如何解决这个错误。我不确定这些信息是否有用,但我正在使用Mac和编辑器IntelliJ。
public class TestCode {
public static void main(String[] args) throws Exception {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("adb devices");
}
}
结果是"Exception in thread "ma
我正在尝试在JSP中获取单选按钮的值。但是我得到了这个错误。当单选按钮值为"All“时,代码可以正常运行,但当单选按钮值为另一个值时,就会出现问题。我打印了属性,但仍然获得了值。我找不出我哪里错了。
错误
ERROR c.p.f.e.GlobalExceptionHandler - [URL] : http://localhost:8080/project/motsach/genre
org.springframework.dao.InvalidDataAccessApiUsageException: No value supplied for the SQL paramete
这是针对分数类的。当我用像"2/4“这样的字符串测试这个分数类时,我得到了以下异常:
java.lang.NumberFormatException: For input string: "".
我认为这与尝试替换空格时的sStringTo方法有关。
public class Util{
static int findGCF(int a, int b){
a = Math.abs(a);
b = Math.abs(b);
while(a != b){
if (a>b) a = a-b; else b = b-a;
我使用下面的代码创建了一个名为.txt的Test.txt文件,它起了作用。现在,我想让java把信息读回给我,当我读回来的时候,我会收到这两段代码之间的错误。我只想写到一个文件,保存它,并能够读取它,这样我就可以创建一个小型数据库。谢谢!
package textFile;
import java.io.*;
import java.lang.*;
import java.util.*;
public class createFile {
private Formatter x;
public void openfile(){
try{
x = new Forma
我很难理解为什么会出现这个错误:
ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
Type "SETX /?" for usage.
实现
C:\Users>setx JAVA_HOME "C:\DOC\JDK64\1.8.0.74"
SUCCESS: Specified value was saved.
C:\Users>setx PATH "%PATH%;%JAVA_HOME%\bin"
ERROR: Inv
当我使用switch case语句在循环中传递字符串时,它提供了以下错误。
1 x X 00
1
java.lang.RuntimeException: INVALID VALUE
at test.main(test.java:28)
在调试时,我发现异常是在字符串中转义字符所在的"x“之后抛出的。我不明白为什么会发生这种情况,它不应该忽略转义字符,而s.charAt(i)应该转到下一个字符吗?
public class test{
public static void main(String [] args){
String s = "1 x