About Question enthuware.ocpjp.v8.2.1822 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ArpRokz
Posts: 15
Joined: Sun Jan 28, 2018 12:38 pm
Contact:

About Question enthuware.ocpjp.v8.2.1822 :

Post by ArpRokz »

I have these questions..

1) Does getNameCount() starts counting from 0 or 1 ?

2) Does it include root when counting ( \ or C:) ?

3)When I run this code in eclipse:

Code: Select all

public class test11
{
  public static void main(String args[])
  {
      Path p1 = Paths.get("photos\\..\\beaches\\.\\calangute\\a.txt");   
      
      Path p2 = p1.normalize(); 
      Path p3 = p1.relativize(p2);
      Path p4 = p2.relativize(p1);
      

      System.out.println(p1);
      System.out.println(p2);
      System.out.println(p3);
      System.out.println(p4);

      System.out.println(     p1.getNameCount()+" "+p2.getNameCount()+" "+     p3.getNameCount()+" "+p4.getNameCount());
  }
}
It ouputs:

photos\..\beaches\.\calangute\a.txt
beaches\calangute\a.txt


6 3 1 1

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1822 :

Post by admin »

1. "count" is the number of elements, so "starting from 0 or 1" is not a valid question here. If there are no elements then the count will be 0. It is the "index" that starts with 0. i.e. index of the first element is 0. If there are 10 elements, the index of the first element is 0 and last is 9.

2. The given path components are separated using the path separators and those components are counted. So, the question whether it includes root or not is not relevant here

3. Please read the explanation. It explains this output.
If you like our products and services, please help us by posting your review here.

BinSlayer
Posts: 10
Joined: Tue Jul 09, 2019 8:33 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1822 :

Post by BinSlayer »

Hi. Did they change the implementation in-between JDK 8 and JDK 11?
Indeed when running the code on JDK 11 it will print out 6 3 1 1.
It would seem to my naked eye that JDK 11 prefers normalizing any path before using it. Could you confirm that I got this right? Thanks.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1822 :

Post by admin »

Yes, it looks like they changed the implementation in Java 11.
The answer has been updated with relevant information.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.

sir_Anduin@yahoo.de
Posts: 62
Joined: Fri Aug 07, 2015 2:16 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1822 :

Post by sir_Anduin@yahoo.de »

I´m at version 1/11 and still get the anser 6 3 9 9

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1822 :

Post by admin »

Fix was in 1.13.
Please update your question bank file.
If you like our products and services, please help us by posting your review here.

sir_Anduin@yahoo.de
Posts: 62
Joined: Fri Aug 07, 2015 2:16 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1822 :

Post by sir_Anduin@yahoo.de »

It says that I am up to date:
Unbenannt.PNG
Unbenannt.PNG (14.04 KiB) Viewed 3663 times
Build : 20190622
ETSV Version: 20190423

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1822 :

Post by admin »

It will notify now.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests