File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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: 20370

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: 15038

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.
Don't get me started about those stupid light bulbs.
subject: Object or ArrayList Syntax Error
It's not a secret anymore!