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/Whats wrong in this code?
Neil
Level 5
Hyderabad
  • 1/13/20
  • 1435views
  • 3comments

Whats wrong in this code?

Question about the task Sam I Am
Java Syntax,  Level 3,  Lesson 6
Under discussion


Display all possible combinations of the words "Sam", "I", "Am".

Hint: there are 6 combinations.
Display each combination on a new line. Do not separate the words.

Consider this example:
IAmSam
AmSamI
...

Requirements:
  • The program should output text.
  • The displayed text should contain 6 lines.
  • The text on each line must be unique.
  • All possible combinations should be displayed.
package com.codegym.task.task03.task0313; /* Sam I Am */ public class Solution { public static void main(String[] args) { //write your code here System.out.println("IAmSam"); System.out.println("ISamAm"); System.out.println("AmISam"); System.out.println("AmSamI"); System.out.println("SamIAM"); System.out.println("SamAmI"); } }
0
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Lunita
Level 4 , Dominican Republic
13 January 2023, 13:52
You have an Upper case M in one of the lines
+1
lalit mehra
Level 4 , India, India
4 September 2021, 13:53
take 3 string
0
Diana Salvador
Level 26 , Sintra, Portugal
13 January 2020, 16:53
I think the error is in line 15: System.out.println("SamIAM"); It should be System.out.println("SamIAm");
+7
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 © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym