This is my code :
这是我的代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String tweet = scan.nextLine();
int link = 0;
int tag = 0;
int at = 0;
int c = 0;
int l = tweet.length();
if (l <= 140) {
while (c < tweet.length()) {
char let = tweet.charAt(c);
if (let == '#') {
tag++;
String hash = tweet.substring(c, c + 2);
if (hash.equals("# ")) {
tag--;
}
} else if (let == '@') {
at++;
String to = tweet.substring(c, c + 2);
if (to.equals("@ ")) {
at--;
}
} else if (let == 'h') {
String http = tweet.substring(c, c + 7);
if (http.equals("https://")) {
link++;
}
}
c++;
}
System.out.println("Number of Hashtags: " + tag);
System.out.println("Number of Attributions: " + at);
System.out.println("Number of Links: " + link);
} else if (l > 140) {
int difference = tweet.length() - 140;
System.out.print("Excess Characters: " + difference);
}
}
}
import java.util.