我有一个创建多个Integer对象的类,并将它们放入LinkedList如下所示:
public class Shares<E> implements Queue<E> {
protected LinkedList<E> L;
public Shares() {
L = new LinkedList<E>();
}
public boolean add(E price) {
System.out.println("How many of these shares would you like?");
Scanner scanInt;
scanInt = new Scanner(System.in);
Integer noShares = scanInt.nextInt();
for (int i = 0; i < noShares; i++) {
L.addLast(price);
}
scanInt.close();
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个应用程序从控制台扫描输入"添加",如果找到,调用add如下所示的方法:
public class Application {
private static Scanner scan;
public static <E> void main(String[] args) { …Run Code Online (Sandbox Code Playgroud) 我设法旋转图像,180 degrees但希望旋转它90 degrees clockwise可以有人编辑我的代码,以便它做到这一点解释.谢谢.
private void rotateClockwise()
{
if(currentImage != null){
int width = currentImage.getWidth();
int height = currentImage.getHeight();
OFImage newImage = new OFImage(width, height);
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
newImage.setPixel( x, height-y-1, currentImage.getPixel(x, y));
}
}
currentImage = newImage;
imagePanel.setImage(currentImage);
frame.pack();
}
}
Run Code Online (Sandbox Code Playgroud)