jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Object or ArrayList Syntax Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Object or ArrayList Syntax Error" Watch "Object or ArrayList Syntax Error" New topic

Object or ArrayList Syntax Error

Justin Tom

Joined: Feb 18, 2008
Posts: 3
Hi. I'm sorta new to Java and OOP and I have this funny error in this method:

What I'm trying to do is to just look at the object on top of the stack because I'm trying to solve a problem about matching brackets together by using stacks and I'm treating each character of a string as their own object.

The error says:

I hope it's just one of my dumb mistakes but I can't figure out how to fix it or why that error happened?
Henry Wong

Joined: Sep 28, 2004
Posts: 20150

This is *not* a valid method signature. Not sure what you are trying to do -- you want to define a method that returns a method?


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14993

Justin T., welcome to JavaRanch. Please check your private messages. You can see them by clicking My Private Messages.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Justin Tom

Joined: Feb 18, 2008
Posts: 3
I'm trying to use the peek method such that when I'm "peeking" into my stack, I won't get an error when the top of the stack is empty. I guess my problem is the return type... but I defined s as

in a constructor. So, shouldn't the return type should be an ArrayList for the peek method? If no why not?
Justin Tom

Joined: Feb 18, 2008
Posts: 3
think I got it now. Silly me, it should have been returning of type Object, not arraylist.
I agree. Here's the link: http://aspose.com/file-tools
subject: Object or ArrayList Syntax Error
It's not a secret anymore!