Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32
  1. #21

    Default Re: tabang in Java. tabang!


    charAt(int index) - Returns the char value at the specified index.


    String myString = "My String";
    System.out.println("Character at index 4: "+myString.charAt(4));
    Output: Character at index 4: t

    Code:
         case '}':
    		if (isBrace(stack.peek().toString().charAt(0)))
    		{
    		     stack.pop();
    		}
    		break;
    Atong sabtun ang logic, english-bisaya..
    Kung ang character sa index 0 kay isBrace(c == '{' || c == '}'), i-pop nako sa stack ang brace.

  2. #22
    Elite Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    1,018

    Default Re: tabang in Java. tabang!

    Ok...so let's further explain how the dot or Dot Notation (.) works.

    Whenever you use the Dot Notation, you have to think about two things.
    The object before the Dot and the method or property after the Dot.

    In java, whenever you access a method or property via dot notation, you can use it as an object right away.

    Let's start with stack.peek()

    If you look at the documentation for Stack it has a method called peek and it returns an Object.
    Stack (Java 2 Platform SE v1.4.2)
    That means, aside from an initial reference to a stack when using peek you gain reference to an Object.

    (Stack) (Object)
    stack . peek()

    Since you now have reference to an object with class Object, you can use its methods and properties right away.
    Object (Java 2 Platform SE 5.0)
    Basing from the documentation, you can find the toString method which returns an object with class String.

    (Stack) (Object) (String)
    stack. peek(). toString().

    Finally, since you now have a reference to a String object, upon looking at its documentation, you can use chatAt(int index) right away.
    String (Java 2 Platform SE v1.4.2)

    (Stack) (Object) (String) (Character)
    stack. peek(). toString(). charAt(index)

    So, in summary, the dot notation allows you to gain access of the object before the dot and use its corresponding methods, fields and other properties.
    Last edited by Klave; 03-01-2012 at 05:10 PM.

  3. #23

    Default Re: tabang in Java. tabang!

    nice pa ka explain in Klave....

  4. #24

    Default Re: tabang in Java. tabang!

    Quote Originally Posted by Klave View Post
    Ok...so let's further explain how the dot or Dot Notation (.) works.

    Whenever you use the Dot Notation, you have to think about two things.
    The object before the Dot and the method or property after the Dot.

    In java, whenever you access a method or property via dot notation, you can use it as an object right away.

    Let's start with stack.peek()

    If you look at the documentation for Stack it has a method called peek and it returns an Object.
    Stack (Java 2 Platform SE v1.4.2)
    That means, aside from an initial reference to a stack when using peek you gain reference to an Object.

    (Stack) (Object)
    stack . peek()

    Since you now have reference to an object with class Object, you can use its methods and properties right away.
    Object (Java 2 Platform SE 5.0)
    Basing from the documentation, you can find the toString method which returns an object with class String.

    (Stack) (Object) (String)
    stack. peek(). toString().

    Finally, since you now have a reference to a String object, upon looking at its documentation, you can use chatAt(int index) right away.
    String (Java 2 Platform SE v1.4.2)

    (Stack) (Object) (String) (Character)
    stack. peek(). toString(). charAt(index)

    So, in summary, the dot notation allows you to gain access of the object before the dot and use its corresponding methods, fields and other properties.
    nice ka bro..!

    @jairoh, hinay-hinayi na jud og sabut ang API sa Java.. hehehe.. sauna ra ko gasulti nga naa ra na sa API, especially sa mga di nimo ma-sabtan..

  5. #25

    Default Re: tabang in Java. tabang!

    good one! nya nasolve nani TS? hehehe

  6. #26
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465

    Default Re: tabang in Java. tabang!

    solved nani! hahaha. nahan lng tawn ko makasabot. di man sad ni activity namo. practice2x lng kunohay ba

  7. #27

    Default Re: tabang in Java. tabang!

    na solve na hagbay ra...hehehe
    crazy_monkey ang banggiitan nga programmer sa Special Team
    Quote Originally Posted by crazy_monkey View Post
    good one! nya nasolve nani TS? hehehe

  8. #28

    Default Re: tabang in Java. tabang!

    kanang toString().charAt(0) gi kuha ra niya ang first character sa string

    sample:

    ABCDEFG

    ang charAt(0) is 'A'

  9. #29

    Default Re: tabang in Java. tabang!

    additional tip about ani nga code:

    Code:
    size = input.length();
    for(int x = 0; x < size; x++)
    kung di na gamiton ang variable nga size outside sa for loop, do it this way instead:

    Code:
    for(int x = 0, size = input.length(); x < size; x++)
    i've been using this ever since nakat-on kog c/c++, applicable gihapon na basta c-like ang programming language nga gigamit such as java. ang advantage kay di na mo-exist outside sa for loop ang variable nga size. this way pwede mka-initiliaze ug daghan nga variable nga sa for loop ra gamiton plus di na mo-conflict outside sa loop.

  10. #30

    Default Re: tabang in Java. tabang!

    Quote Originally Posted by SuperStar View Post
    Code:
        public boolean isParenthesis(char c)
        {
            return c == '(' || c == ')';
        }
    is equivalent to

    Code:
        public boolean isParenthesis(char c)
        {
                  if (c == '(' || c == ')')
            return true;
                  else
                    return false;
        }
    tan-awa ari bro kay naa diri ang nindot nga sample ug simple pag ka explain
    The ? : operator in Java
    hope this helps
    superstar ask lang ko ba, diba ang boolean kai true or false raman iya pwde e.return.? pwde d.i nang ina.ana.?

    thanks

  11.    Advertisement

Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

 
  1. Jeepney fare history in Cebu.. tabang istoryans..
    By nodols3 in forum Business, Finance & Economics Discussions
    Replies: 51
    Last Post: 06-14-2016, 03:27 PM
  2. Tabang mga Java programmers!!!
    By IGN.Boss Wax in forum Programming
    Replies: 4
    Last Post: 11-08-2012, 02:17 PM
  3. How to clear buffer in Java?
    By ares623 in forum Programming
    Replies: 17
    Last Post: 09-22-2009, 11:20 AM
  4. TABANG In good terms mi sa manghod sa ako EX-
    By truelegitballer in forum Relationships (Old)
    Replies: 146
    Last Post: 05-17-2009, 01:04 AM
  5. image bigger than its panel in java
    By manick in forum Programming
    Replies: 4
    Last Post: 09-11-2008, 08:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top