CodeGym
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
CodeGym/Help with Java Tasks/This entire course is a joke
Michal
Level 26
Lodz
  • 11.06.2020
  • 529views
  • 3comments

This entire course is a joke

Question about the task New functionality!
Java Multithreading,  Level 5,  Lesson 2
Under discussion


Using an enum, implement the getLetterPosition() method, which must return a letter's position.
The position of the letter A is 1.

Requirements:
  • The Solution class must have an enum called Alphabet.
  • Alphabet must contain the 26 letters of the English alphabet, in alphabetical order.
  • The Alphabet class's getLetterPosition() method must return a letter's position in the alphabet.
  • The getLetterPosition() method must call the ordinal method.
package com.codegym.task.task25.task2501; /* New functionality! */ public class Solution { public static void main(String[] args) { System.out.println(Alphabet.G.getLetterPosition()); } public enum Alphabet { A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z; private int ordinal; public int getLetterPosition() { return Alphabet.this.ordinal + 1; } } }
0
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
ABDOULRAHMAN ADEN DAHER
Level 31 , DJBOUTI, Djibouti
2 November 2024, 08:02
return ordinal() + 1;
+2
WIDMO
Level 25 , Gdańsk, Poland
Expert
30 June 2020, 16:36
You should remove, 19 line:
private int ordinal;
and change 22 line to :
return Alphabet.this.ordinal() + 1;
remember that ordinal is a method, so you need to put brackets.
0
Eelke 't Hooft
Level 27 , Amsterdam, Netherlands
22 June 2020, 08:17
Should be fine if you remove the private int ordinal.
0
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2025 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2025 CodeGym