Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class Main {
  4. public static void main(String[] args) {
  5. System.out.println("hello world");
  6. System.out.println(drawTriangle(5));
  7. hashTweets("dahvfkl vsjlkh dshdl #slbns @bsnjklvn vndfi#vfdvns");
  8. }
  9. public static String drawTriangle(int sizetri){
  10. String tri = "";
  11. for(int i =0; i <= sizetri; i++){
  12. tri += "\n";
  13. for(int j =0; j < i; j++){
  14. tri += "#";
  15. }
  16. }
  17. return tri;
  18. }
  19.  
  20. public static void hashTweets(String tweet){
  21. String[] tweetlist = tweet.split(" ");
  22. List<String> hashMentions = new ArrayList<String>();
  23. for (int i = 0; i < tweetlist.length; i++){
  24. boolean isHash = (tweetlist[i].charAt(0) == '#');
  25. boolean isMention =(tweetlist[i].charAt(0) == '@');
  26. if (isHash || isMention){
  27. hashMentions.add(tweetlist[i]);
  28. }
  29. }
  30. System.out.println(hashMentions);
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement