aspose file tools*
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
Author

Object or ArrayList Syntax Error

Justin Tom
Greenhorn

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
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40



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?

Henry


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: 14273
    
  21

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
Greenhorn

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
Greenhorn

Joined: Feb 18, 2008
Posts: 3
think I got it now. Silly me, it should have been returning of type Object, not arraylist.
 
Consider Paul's rocket mass heater.
 
subject: Object or ArrayList Syntax Error