CodeGym /Java Course /Java Syntax /Practice displaying the stack trace

Practice displaying the stack trace

Java Syntax
Level 9 , Lesson 2
Available

"Hi, Amigo!"

"Hi, Diego!"

"Here’s a small task about displaying the stack trace."

9
Task
New Java Syntax, level 9, lesson 2
Locked
Octal converter
The public static toOctal(int) method must convert the integer received as an input parameter from the decimal numeral system into octal. And conversely, the public static toDecimal(int) method converts from the octal system into decimal. The methods only work with positive numbers. If the input par
9
Task
New Java Syntax, level 9, lesson 2
Locked
Binary converter
The public static toBinary(int) method must convert the integer received as an input parameter from the decimal numeral system to binary and return its string representation. And conversely, the public static toDecimal(String) method converts from the string representation of a binary number to a de
9
Task
New Java Syntax, level 9, lesson 2
Locked
Hexadecimal converter
The public static toHex(String) method must convert the integer received as an input parameter from the decimal numeral system to hexadecimal and return its string representation. And conversely, the public static toDecimal(String) method converts from the string representation of a hexadecimal numb
9
Task
New Java Syntax, level 9, lesson 2
Locked
Binary to hexadecimal converter
The public static toHex(String) method must convert the string representation of a binary number, received as an input parameter, from the binary numeral system to hexadecimal and return its string representation. And conversely, the public static toBinary(String) method converts from the string rep
Comments (55)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Japa Level 14
19 May 2023
if lessons only teach you use foreach, use for(i) iterator to check value what is needed.
Melody Ye Level 29, France, France
6 March 2023
For anyone one's confused about these tasks, there are some info might be useful: "return Thread.currentThread().getStackTrace()[2].getMethodName();}" This code is a method that returns the name of the method that called the current method, using the stack trace of the currently executing thread in Java. Let's break it down: Thread.currentThread() returns a reference to the currently executing thread. getStackTrace() returns an array of StackTraceElement objects representing the method call stack for that thread. [2] is used to access the third element of the stack trace array (the element at index 0 is the method that called getStackTrace(), the element at index 1 is the getStackTrace() method itself, and the element at index 2 is the method that called the method that called getStackTrace()). getMethodName() is called on the StackTraceElement object at index 2 to retrieve the name of the method that called the current method. So in summary, return Thread.currentThread().getStackTrace()[2].getMethodName(); returns the name of the method that called the current method, using the stack trace of the currently executing thread.
Ndatta Fall Level 25, United States of America, United States
29 March 2023
this was so helpful! God bless you!
Daniel Ketcheson Level 28, Canada
25 May 2023
Daunting at first, this lesson became kind of easy once I read your explanation. Another thank you!
Xavi Martin Level 22 Expert
5 December 2022
The worst lesson of all, I understand that as a programmer you have to wake up but could you explain something? It is supposed that the course is to learn and if they put you some exercises that you do not even know where to start looking for when it would be much more useful to explain it well and instead of wasting time searching without success, practice more, I say...
LX40GL Level 28, Birmingham, United States
8 September 2022
I'm using Google. And I downloaded Java API document at Level 09. I don't ask CodeGym to explain everything. But at least give us some basics or keywords. This lesson is confusing.
Jonaskinny Level 25, Redondo Beach, United States
20 February 2022
This one got me initially since I was not counting the getStackTrack() in the method call chain. Good reminder !!
PeterC Level 28, France, France
6 December 2021
Don't use COPY - PASTE. Type it all manually - this is the best way to develop muscle memory.
Ricky Level 21, Norway
25 January 2022
Although unbelievably tedious, this is unfortunately true. Good tip
Justin Smith Level 41, Greenfield, USA, United States
21 July 2021
Other than debugging, what would be the actual use of the getLineNumber method?
Ashraf Khalifa Level 9, Coventry, United Kingdom
20 June 2021
Felt like I was thrown in the deep end. Not enough explanation on the subject.
John Squirrels Level 41, San Francisco, Poland
22 June 2021
If you have got some questions, please ask us.
Anonymous #10775689 Level 14, United Kingdom
2 August 2021
I think the comments/replies here show that an extra lesson with explanation would really help learn this topic.
Michael Level 10, Dresden, Germany
12 August 2021
Instead of wasting so much time looking around independently, I do prefer to be better prepared for the challenges. Concerning asking questions: The Codegym team and community are very active and responsive, but sometimes it takes time to get an answer. Quite simply, codegym is not a personal tutoring platform where the direct nature of the interaction is prominent. Many of us simply do need more explanations.
ImDevin Level 15, Old Town, United States
6 May 2021
Well, I learned something about StackTrace, but this was a very strange set of tasks.
18 April 2021
A detailed tutorial or, at a minimum, a table listing all the methods and their use would be preferred and could then be used to apply the knowledge to the exercises for practicing the usage and application. I did my best to complete each on my own and when unsuccessful, I would compare to the solution, copy and paste it in, and then analyze the resulting completed program.