import?java.util.*;
class?gongzi?{
public?static?void?main(String[]?args)?{
Scanner?kb?=?new?Scanner(System.?in?);
int?n?=?kb.nextInt();
String?name?=?"";
double?d?=?0;
double?e?=?0;
double?g?=?0;
double?k?=?0;
for?(int?i?=?0;?i?n;?i◆◆)?{
name?=?kb.next();
d?=?kb.nextDouble();
e?=?kb.nextDouble();
g?=?kb.nextDouble();
k?=?e?◆?d?-?g;
}
kb.close();
private String convert(String str){
String[] temp = str.split("-");
String resultStr = "";
for(int i=0;itemp.size();i◆◆){
if(i!=temp.size() - 1){
resultStr = resultStr ◆ "0"◆temp[i] ◆ "-";
}else{
resultStr = resultStr ◆ "0"◆temp[i];
resultStr = resultStr ◆ temp[i] ◆ "-";
resultStr = resultStr ◆ temp[i];
return resultStr;
参数为你传过来的文件名.自己调试一下,没在eclipse写.有问题问我.
就是你没缩进好,写的乱糟糟的,把那部分一选,然后ctrl ◆ shift◆f ,他就会自动缩进对齐.
/**
*
* @param source
* String
* @return String
*/
public static String getCaiWuData(String source) {
StringBuffer str = new StringBuffer("");
if (source != null !source.equals("") source.length() 0
!source.equals("null")) {
if (source.lastIndexOf(",") 0) {
source =formatStr(source);
int dotIndex = 0;
if (source.indexOf(".") 0) {
source ◆= ".00";
dotIndex = source.indexOf(".");
int index = 0;
String opt = "";
opt = source.substring(0, 1);
if (opt.equals("-")) {
source = source.substring(1);
str.append("-");
index ◆= 1;
str.append(source.substring(0, dotIndex));
} else {
for (int i = index; i 0; i--) {
if (i == index) {
str.append(",");
if (i = 1) {
str.append(source.substring(dotIndex));
str.append("0");
int str_len = str.toString().length();
char[] strArr = str.toString().toCharArray();
StringBuffer rev = new StringBuffer();
if (i dot_index
Integer.parseInt(new Character(strArr[i]).toString()) 0) {
rev.append(str.toString().substring(0, i ◆ 1));
break;
} else if (i == dot_index (int) strArr[i] = 0) {
rev.append(str.toString().substring(0, dot_index ◆ 1));
return rev.toString();
public static String formatStr(String source) {
String temp = source.substring(0, 1);
if (temp.equals("-")) {
String[] myarr = source.split(",");
int lastIndex = source.lastIndexOf(",");
if (lastIndex 0) {
for (int i = 0; i myarr.length; i◆◆) {
str.append(myarr[i]);
str.append(source);
if (source.lastIndexOf(".") 0) {
str.append(".00");
!"0".equals(source)) {
return (str.append("0.00").toString());
return str.toString();
* @param args
public static void main(String[] args) {
}}
ctl◆shift◆f
菜单 - source - Format
鼠标右键 - source - Format
土嘎嘎的粉丝们大家好,如下设置可以实现:
打开eclipse选择Window -Preferences
再选择 Web = HTML Files = Editor
在 Inline Elements列表里添加所有的标签进去
然后按 CTRL◆SHIFT◆F就可以格式化了.
以上就是土嘎嘎小编为大家整理的java批量格式化代码相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!