我试图从用逗号分隔的文件中读取x,y坐标.但是,元素未正确添加到ArrayList.我在哪里错了?
ArrayList<Double> xpointArrayList = new ArrayList<Double>();
ArrayList<Double> ypointArrayList = new ArrayList<Double>();
try {
BufferedReader input = new BufferedReader(new FileReader(args[0]));
String line;
while ((line = input.readLine()) != null) {
line = input.readLine();
String[] splitLine = line.split(",");
double xValue = Double.parseDouble(splitLine[0]);
double yValue = Double.parseDouble(splitLine[1]);
xpointArrayList.add(xValue);
ypointArrayList.add(yValue);
}
input.close();
} catch (IOException e) {
} catch (NullPointerException npe) {
}
double[] xpoints = new double[xpointArrayList.size()];
for (int i = 0; i < xpoints.length; i++) {
xpoints[i] = xpointArrayList.get(i);
}
double[] ypoints = …
Run Code Online (Sandbox Code Playgroud) 这个问题可能对你们很多人来说很简单,但是我坚持了下来:/如果条件在周围没有的情况下工作,但是当我把它放在我的日志中什么都没有的时候
此REresponse是来自服务器的响应,具有客户端发送给它的特定ID以及T或F作为结果,以确保唯一的客户端收到它是发送它的人
boolean recieved = false
String REresponse = (String) sInput.readObject();
while(recieved=false)
{
if (REresponse.equals("('T','"+newRID+"')")){
Log.i(LOGTAG,"you made it");
recieved = true;
}else if (REresponse.equals("('F','"+newRID+"')")){
Log.i(LOGTAG,"you failed");
recieved=true;
}else{
Log.i(LOGTAG,REresponse);
Log.i(LOGTAG,"some thing is wrong");
Run Code Online (Sandbox Code Playgroud)
我也尝试使用案例条件,但确实是这样做的
我试图将字符串"5/23/14 02:23:24"从Eclipse中的String转换为要插入到SQL语句中的Date.我的代码如下:
String dateAndTime = "5/23/14 02:23:24";
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
Date date = sdf.parse(dateAndTime);
long dateLong = date.getTime();
insertStatement.setDate(1, new java.sql.Date(dateLong));
Run Code Online (Sandbox Code Playgroud)
我希望看到
23-MAY-2014 2.23.24.000000000 PM
Run Code Online (Sandbox Code Playgroud)
在我的桌子上,但我看到了
23-MAY-2014 12.00.00.000000000 AM
Run Code Online (Sandbox Code Playgroud)
谁能说清楚我做错了什么?
谢谢!
我遇到第34行的编译错误.我已经尝试将变量设置为等于自身并修复了编译错误,但它没有正确运行程序.
这是错误:
BaseConverter.java:34: error: illegal start of expression
for(iCount=; iCount>=0; iCount--)
Run Code Online (Sandbox Code Playgroud)
码:
import java.util.Scanner;
public class BaseConverter
{
public static void main(String []args)
{
Scanner Keyboard=new Scanner(System.in);
int iConvertNum;
int iFromBase;
int iToBase;
int iCount;
int iQuotent=0;
int[] iRemander= new int[100];
System.out.print("Enter the positive integer you want to convert: ");
iConvertNum=Keyboard.nextInt();
System.out.print("\nEnter the base you are converting from(1-16): ");
iFromBase=Keyboard.nextInt();
System.out.print("\nEnter the base you are converting to(1-16): ");
iToBase=Keyboard.nextInt();
//if(iFromBase<iToBase)
//{
for(iCount=0; iQuotent>0; iCount++)
{
iRemander[iCount]=iConvertNum/iToBase;
iQuotent=(iConvertNum/(iToBase+iRemander[iCount]));
iConvertNum=iQuotent;
//return iRemander[iCount]; …
Run Code Online (Sandbox Code Playgroud) 我在错误流而不是输入流中获得以下命令的输出
Runtime rt = Runtime.getRuntime();
ProcessBuilder builder = new ProcessBuilder(new String[]{"cmd.exe","/c","java -version"});
Process pr = builder.start();
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String line=input.readLine();
System.out.println(line);
Run Code Online (Sandbox Code Playgroud)
请解释
在java中,我知道最终变量值无法更改.请参阅以下程序并帮助我如何更改最终值.
public class MainClass {
final static int name=123;
public static void main(String[] args) {
System.out.println(name+123);
}
}
Run Code Online (Sandbox Code Playgroud)
输出是246**
谢谢!