aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes examlab,q-11(compilation error reasoning seems goes on other way) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "examlab,q-11(compilation error reasoning seems goes on other way)" Watch "examlab,q-11(compilation error reasoning seems goes on other way)" New topic
Author

examlab,q-11(compilation error reasoning seems goes on other way)

Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432


result:
according to me,i thought it was error coz the collection has not been sorted before searching in.am i right here?

but according to the simulator,it was coz st on line 1 has not been casted to list.
if line1 is modified to as per simulator says below,cabove code should compile but it doesn't.


SCJP 6 | FB : Java Certifications-Help. | India Against Corruption
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Thats because linkedlist is a Collection not Collections.


SCJP 1.6 96%
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

Neha Daga wrote:Thats because linkedlist is a Collection not Collections.

NO,
list is an in interface i.e.Collection.
linkedlist is a class(Collections) that implements list.
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Arjun Srivastava wrote:
list is an in interface i.e.Collection.
linkedlist is a class(Collections) that implements list.


Yes, but I dont see Linkedlist extending Collections class anywhere.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Howdy Arjun!

Did you check what is the compiler error in the first place?


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

sorry, i am so dumb,above code has been modified it was collection ,not collections on line2
but error persists,cannot find symbol on line1.
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
try casting 'st' to List<String> it will work fine. And there is no compiler error its compiler warning because of mixing generic and non generic collections.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Please, try to compile the code from the first post with the change you already posted (casting to List).

On my computer it works just fine...
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

Neha Daga wrote:try casting 'st' to List<String> it will work fine. And there is no compiler error its compiler warning because of mixing generic and non generic collections.

yea ,this casting of st to(List<String>) works fine instead of (List)(as given in simulator)

Pedro Kowalski wrote:Please, try to compile the code from the first post with the change you already posted (casting to List).
On my computer it works just fine...

no pedro, casting st to (List) only didn't work in my system.
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

according to me,i thought it was error coz the collection has not been sorted before searching in.am i right here?
but it was not the case why so,how we can able to search without doing sorting?
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Arjun Srivastava wrote:according to me,i thought it was error coz the collection has not been sorted before searching in.am i right here?
but it was not the case why so,how we can able to search without doing sorting?

Hey, Arjun! => UseRealWords Does the compiler have the sense of sorting? It checks the syntax of your code, that's only!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

Abimaran Kugathasan wrote:
Does the compiler have the sense of sorting? It checks the syntax of your code, that's only!

got it.
if the array or collection has not been sorted before searching,then output will not be predictable.
i thought it was a compiler error,thank god i got to know this thing before exam.
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Arjun Srivastava wrote:
Abimaran Kugathasan wrote:
Does the compiler have the sense of sorting? It checks the syntax of your code, that's only!

got it.
if the array or collection has not been sorted before searching,then output will not be predictable.

Exactly!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: examlab,q-11(compilation error reasoning seems goes on other way)