Specifications

Sun Services
Java™ Programming Language
Module 13, slide 16 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Using the synchronized Keyword
1 public class MyStack {
2
3 int idx = 0;
4 char [] data = new char[6];
5
6 public void push(char c) {
7 data[idx] = c;
8 idx++;
9 }
10
11 public char pop() {
12 idx--;
13 return data[idx];
14 }
15 }