Java 实例 - 旋转向量

Java 教程 · 2019-02-11 14:57:52

以下实例演示了使用 swap() 函数来旋转向量:

Main.java 文件

import java.util.Collections; import java.util.Vector; public class Main { public static void main(String[] args) { Vector<String> v = new Vector(); v.add("1"); v.add("2"); v.add("3"); v.add("4"); v.add("5"); System.out.println(v); Collections.swap(v, 0, 4); System.out.println("旋转后"); System.out.println(v); } }

以上代码运行输出结果为:

1 2 3 4 5 
旋转后
5 2 3 4 1

点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

Domain-Driven Design

Domain-Driven Design

Eric Evans / Addison-Wesley Professional / 2003-8-30 / USD 74.99

"Eric Evans has written a fantastic book on how you can make the design of your software match your mental model of the problem domain you are addressing. "His book is very compatible with XP. It is n......一起来看看 《Domain-Driven Design》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具