User Profile

Collapse

Profile Sidebar

Collapse
Parth Gallen
Parth Gallen
Last Activity: Nov 24 '10, 03:10 AM
Joined: Nov 14 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Parth Gallen
    replied to AddActionListener method
    in Java
    button b prints out "New Game", button b1 "Solving".
    Not saying it's a perfect way but it looks simple enough to me this way:

    Code:
    ActionListener al = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              if (e.getActionCommand().equals("New Game")) {
              System.out.println("New Game");
            } else if (e.getActionCommand().equals("Solve"))
    ...
    See more | Go to post

    Leave a comment:


  • Parth Gallen
    replied to count number of words in a string
    in Java
    "one&two#three| four" will return as 4 words.
    "I'm here" 3 words and so on.
    Just didn't think " " is enough to separate words.

    Code:
    public static int countWords(String s) {
        int counter = 0;
        boolean word = false;
        int endOfLine = s.length()-1;
    
        for (int i = 0; i < s.length(); i++) {
          //if the char is letter, word = true.
    ...
    See more | Go to post

    Leave a comment:


  • Parth Gallen
    started a topic isDigit & isLetter methods
    in Java

    isDigit & isLetter methods

    Character.isDig it() or Character.isLet ter() in Java.lang work of course, but I had to make my own solution as homework so here they are:


    isDigit method:
    Code:
    static boolean isDigit(char c) {
    return (c <= '9' & c >= '0');
    }
    isLetter method:
    Code:
    static boolean isLetter(char c) {
    return (c <= 'z' & c >= 'a' || c<='Z' & c>='A');
    }
    Are...
    See more | Go to post
No activity results to display
Show More
Working...