этот код двойной во время цикла! но не двойной ... только один цикл> Конец .. plz help me .. Я хочу двойную петлю для while. не двойной цикл для hasNext()?Не делайте двойной цикл (пока) как HasNext()?
--------------------------- редактировать --------------
Прости. Я ошибся. Неуклюжий английский. «Не делайте двойной цикл (пока) как HasNext()?» Что я прошу. Извините, я не вежлив. Положите «Пока» он «HasNext()» не смог повторить первый цикл. Я хотел бы создать подобное умножение. Пожалуйста, помогите мне.
import java.io.IOException;
import java.net.MalformedURLException;
import org.geotools.data.shapefile.files.ShpFiles;
import org.geotools.data.shapefile.shp.ShapefileException;
import org.geotools.data.shapefile.shp.ShapefileReader;
import org.geotools.data.shapefile.shp.ShapefileReader.Record;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
class Point {
double x;
double y;
Point(double x2, double y2) {
this.x = x2;
this.y = y2;
}
static double distance(Point p1, Point p2) {
double dist;
dist = Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
return dist;
}
}
public class KFunction {
private static double X;
private static double Y;
private static double X1;
private static double Y1;
public static void main(String[] args) {
ShapefileReader r = null;
ShapefileReader r2 = null;
try {
ShpFiles shpFile = new ShpFiles("Juvenile_Offenders_in_Cardiff.shp");
ShpFiles shpFile2 = new ShpFiles("Juvenile_Offenders_in_Cardiff.shp");
GeometryFactory geometryFactory = new GeometryFactory();
r = new ShapefileReader(shpFile, true, false, geometryFactory);
r2 = new ShapefileReader(shpFile2, true, false, geometryFactory);
Record record2 = r2.nextRecord();
Geometry shape2 = (Geometry) record2.shape();
com.vividsolutions.jts.geom.Point centroid2 = shape2.getCentroid();
int i = 0;
boolean A = r2.hasNext();
while (A) {
X = centroid2.getX();
Y = centroid2.getY();
while (r.hasNext()) {
System.out.println("No." + i);
Record record = r.nextRecord();
Geometry shape = (Geometry) record.shape();
com.vividsolutions.jts.geom.Point centroid = shape.getCentroid();
X1 = centroid.getX();
Y1 = centroid.getY();
Point p1 = new Point(X, Y);
Point p2 = new Point(X1, Y1);
double result = Point.distance(p1, p2);
System.out.println("X : " + X + " Y : " + Y + " X1 : " + X1 + " Y1 : " + Y1);
System.out.println("두 점 사이의 거리 : " + result);
System.out.println("---------------------------");
i++;
}
break;
}
} catch (MalformedURLException e1) {
e1.printStackTrace();
} catch (ShapefileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Пожалуйста, не плачьте в названии. – Maroun
Я плачу прямо сейчас – Chad
прошу прояснить ваш вопрос: «Я хочу, чтобы двойной цикл» был настолько широким, что мы не можем вам помочь – Peter