• Post Reply Bookmark Topic Watch Topic
  • New Topic

getStackTrace don't work  RSS feed

 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code as the I get can't find symbol for the four methods class, file, method, lineNumber. it may be a silly error but I don't found.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please copy/paste the error exactly as it is displayed to you.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to call getClassName() on an array which is illegal. You need to get an individual element from the array and call getClassName() on that element.
 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I amn't working with IDE but the error is
can't find symbol
element.getClassName();
element.getMethodName();
element.getLineNumber();
element.getFileName();

but as powel answer do you mean I have to do the following
element[0].getClassName(); for example or what I have to do
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getClassName()??
Shouldn't that be getClass().getName()
 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a tutorial that I am learning from is an array of StackTraceElement using getClassName() method like that but the tutorial was dealing with many exceptions, here I want to deal with only one exception like the code here.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You were right. It is StackTraceElement#getClassName(), and it does something different from getClass().getName().
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should of course be element[i].getClassName()
And call the array elements rather than element.
 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok will try your recmmendation by calling the methd under array element.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try a for‑each loop:-
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!