CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Start learning now
  • All questions
Vinay
Level 11
  • 07.09.2020
  • 520views
  • 1comment

Create 5 Zerg objects error.

Question about the task Hello, StarCraft!
Java Syntax,  Level 3,  Lesson 4
Resolved

Create 5 Zerg units, 3 Protoss units and 4 Terran units.
Give them all unique names.

Requirements:
  • Don't change the Zerg, Protoss, and Terran classes.
  • Create 5 Zerg objects and name each of them.
  • Create 3 Protoss objects and name each of them.
  • Create 4 Terran objects and name each of them.
package com.codegym.task.task03.task0307; /* Hello, StarCraft! */ public class Solution { public static void main(String[] args) { //write your code here Zerg zerg1 = new Zerg(); Zerg zerg2 = new Zerg(); Zerg zerg3 = new Zerg(); Zerg zerg4 = new Zerg(); Zerg zerg5 = new Zerg(); zerg1.name = "joe"; zerg2.name = "jack"; zerg3.name = "qw"; zerg4.name = "bro"; zerg5.name = "buck"; Protoss f = new Protoss(); Protoss g = new Protoss(); Protoss h = new Protoss(); f.name = "qxz"; g.name = "wxz"; h.name = "exz"; Terran i = new Terran(); Terran j = new Terran(); Terran k = new Terran(); Terran l = new Terran(); i.name = "qxx"; j.name = "wxx"; k.name = "exx"; l.name = "iop"; } public static class Zerg { public static String name; } public static class Protoss { public String name; } public static class Terran { public String name; } }
0
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Misiu
Level 41 , Gdansk, Poland
7 September 2020, 19:00solution
Line 42. Field was not static.
+3
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • 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 Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.