• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Queues in java

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please, help me rectify the errors in the following program:
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yogesh. Welcome to the Ranch!

For a start, then, you're going to have to tell us what the errors are. In detail.
 
yogesh singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ExamImmutableQueueImpl.java 5 class ExamImmutableQueue is public, should be declared in a file named ExamImmutableQueue.java
Error ExamImmutableQueueImpl.java 28 incompatible types
Error ExamImmutableQueueImpl.java 35 incompatible types
Error ExamPeekableQueueImpl.java 7 class ExamPeekableQueue is public, should be declared in a file named ExamPeekableQueue.java
Error ExamPeekableQueueImpl.java 16 ExamPeekableQueueImpl is not abstract and does not override abstract method peekMinimum() in ExamPeekableQueue
Error found java.util.LinkedList
Error found java.util.LinkedList
Error required ExamImmutableQueue
Error required ExamImmutableQueue

well these are the errors on compiling the code.
 
Ranch Hand
Posts: 47
MyEclipse IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

yogesh singh wrote:ExamImmutableQueueImpl.java 5 class ExamImmutableQueue is public, should be declared in a file named ExamImmutableQueue.java
Error ExamImmutableQueueImpl.java 28 incompatible types
Error ExamImmutableQueueImpl.java 35 incompatible types
Error ExamPeekableQueueImpl.java 7 class ExamPeekableQueue is public, should be declared in a file named ExamPeekableQueue.java
Error ExamPeekableQueueImpl.java 16 ExamPeekableQueueImpl is not abstract and does not override abstract method peekMinimum() in ExamPeekableQueue
Error found java.util.LinkedList
Error found java.util.LinkedList
Error required ExamImmutableQueue
Error required ExamImmutableQueue

well these are the errors on compiling the code.




the very first the filename and the public class should be same...in your case your filename is ExamImmutableQueueImpl.java but your interface ExamImmutableQueue is public and it is not allowed
as only one public class is allowed per source file..
hope this helps
Ankit
 
yogesh singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Dan wrote:

yogesh singh wrote:ExamImmutableQueueImpl.java 5 class ExamImmutableQueue is public, should be declared in a file named ExamImmutableQueue.java
Error ExamImmutableQueueImpl.java 28 incompatible types
Error ExamImmutableQueueImpl.java 35 incompatible types
Error ExamPeekableQueueImpl.java 7 class ExamPeekableQueue is public, should be declared in a file named ExamPeekableQueue.java
Error ExamPeekableQueueImpl.java 16 ExamPeekableQueueImpl is not abstract and does not override abstract method peekMinimum() in ExamPeekableQueue
Error found java.util.LinkedList
Error found java.util.LinkedList
Error required ExamImmutableQueue
Error required ExamImmutableQueue

well these are the errors on compiling the code.




the very first the filename and the public class should be same...in your case your filename is ExamImmutableQueueImpl.java but your interface ExamImmutableQueue is public and it is not allowed
as only one public class is allowed per source file..
hope this helps
Ankit



updated my code accordingly, still the error persists,

ExamPeekableQueueImpl.java 7 class ExamPeekableQueue is public, should be declared in a file named ExamPeekableQueue.java


where ExamPeekableQueue is not a class its the interface
 
yogesh singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please ignore the earlier message, there was some mistake in that one.
 
Ankit Dan
Ranch Hand
Posts: 47
MyEclipse IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

where ExamPeekableQueue is not a class its the interface


but the compiler treats it as a class you can make out from the compiler error:

class ExamImmutableQueue is public, should be declared in a file named ExamImmutableQueue.java




From section 7.6 of the JLS:


When packages are stored in a file system (§7.2.1), the host system may choose to enforce the restriction that it is a compile-time error if a type is not found in a file under a name composed of the type name plus an extension (such as .java or .jav) if either of the following is true:

>The type is referred to by code in other compilation units of the package in which the type is declared.
>The type is declared public (and therefore is potentially accessible from code in other packages).

This restriction implies that there must be at most one such type per compilation unit. This restriction makes it easy for a compiler for the Java programming language or an implementation of the Java virtual machine to find a named class within a package; for example, the source code for a public type wet.sprocket.Toad would be found in a file Toad.java in the directory wet/sprocket, and the corresponding object code would be found in the file Toad.class in the same directory.



so whether it is interface or class...only one public i hope you got this one

there are few more errors i suppose other than this one..please post them after rectifying this error..

Happy to help
Ankit
 
yogesh singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Dan wrote:

where ExamPeekableQueue is not a class its the interface


but the compiler treats it as a class you can make out from the compiler error:

class ExamImmutableQueue is public, should be declared in a file named ExamImmutableQueue.java




From section 7.6 of the JLS:


When packages are stored in a file system (§7.2.1), the host system may choose to enforce the restriction that it is a compile-time error if a type is not found in a file under a name composed of the type name plus an extension (such as .java or .jav) if either of the following is true:

>The type is referred to by code in other compilation units of the package in which the type is declared.
>The type is declared public (and therefore is potentially accessible from code in other packages).

This restriction implies that there must be at most one such type per compilation unit. This restriction makes it easy for a compiler for the Java programming language or an implementation of the Java virtual machine to find a named class within a package; for example, the source code for a public type wet.sprocket.Toad would be found in a file Toad.java in the directory wet/sprocket, and the corresponding object code would be found in the file Toad.class in the same directory.



so whether it is interface or class...only one public i hope you got this one

there are few more errors i suppose other than this one..please post them after rectifying this error..

Happy to help
Ankit



yes, done with all the errors,
can you please help me to add elements to my queue in the program?
 
Ankit Dan
Ranch Hand
Posts: 47
MyEclipse IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try it out and if you dont get anything .....
try again
try again
final step : help from others

Happy to help
Ankit
 
yogesh singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Dan wrote:Try it out and if you dont get anything .....
try again
try again
final step : help from others

Happy to help
Ankit


done thank you for the help guys.
 
Did you miss me? Did you miss this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic