Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Java Help


Kajamaz
 Share

Recommended Posts

Well, i'm doing some questions in Java and i have some issues with some questions.

double rub[] = {23.0, -102.1, 88.23, 111, 12.02, 189.119, 299.88};

double dub[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};

Write a single line of code (using arraycopy) that will result in dub looking like this:

{1, 2, 3, 4, 111, 12.02, 189.119, 8, 9}

double[] zz, top = {12.1, 13.1, 14.1, 15.1, 18};

zz = top;

zz[2] = 99;

top[3] = 100.2;

Show what “both” arrays would look like at the completion of the above code.

char[] a, b;

a = “Groovy dude”.toCharArray( );

b = “I like this”.toCharArray( );

System.arraycopy(a, 1, b, 0, 4);

What do the two arrays look like at the completion of this code?

Assume the array myArray in #12 has been correctly sorted. What would be printed with

the following?

System.out.println( Arrays.binarySearch(myArray, 56) );

System.out.println( Arrays.binarySearch(myArray, 102) );

What does the following print?

int xc[] = {123, 97, -102, 17};

int pk[] = {123, 79, -102, 17};

int gs[] = {123, 97, -102, 17};

System.out.println( Arrays.equals(xc, pk) + “\n” + Arrays.equals(xc, gs));

I Cant Answer those 5 Questions, can someone answer them or one of them? For Some reason i get compiler issues.
Link to comment
Share on other sites

double rub[] = {23.0, -102.1, 88.23, 111, 12.02, 189.119, 299.88};[/font]

double dub[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};[/font]

Write a single line of code (using arraycopy) that will result in dub looking like this:

{1, 2, 3, 4, 111, 12.02, 189.119, 8, 9}

System.arraycopy(rub,3,dub,4,3); //Copy 3 elements from rub starting at index 3 into dub starting at index 4.

double[] zz, top = {12.1, 13.1, 14.1, 15.1, 18};[/font]

zz = top;

zz[2] = 99;

top[3] = 100.2;

Show what “both” arrays would look like at the completion of the above code.

zz and top = {12.1,13.1,99,100.2,18}; //Since arrays are actually object references, so setting zz to top results in a reference.

char[] a, b;[/font]

a = “Groovy dude”.toCharArray( );

b = “I like this”.toCharArray( );

System.arraycopy(a, 1, b, 0, 4);

What do the two arrays look like at the completion of this code?

a = {G,r,o,o,v,y, ,d,u,d,e}

b = {r,o,o,v,k,e, ,t,h,i,s}

//Copies "roov" from Groovy into array b.

Assume the array myArray in #12 has been correctly sorted. What would be printed with

the following?

System.out.println( Arrays.binarySearch(myArray, 56) );

System.out.println( Arrays.binarySearch(myArray, 102) );

Where is #12?

What does the following print?

int xc[] = {123, 97, -102, 17};[/font]

int pk[] = {123, 79, -102, 17};[/font]

int gs[] = {123, 97, -102, 17};[/font]

System.out.println( Arrays.equals(xc, pk) + “\n” + Arrays.equals(xc, gs));

false, true

Since the _contents_ of the array xc != pk, and the contents of xc and gs are the same.
Link to comment
Share on other sites

> double rub[] = {23.0, -102.1, 88.23, 111, 12.02, 189.119, 299.88};[/font]
>
> double dub[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};[/font]
>
> Write a single line of code (using arraycopy) that will result in dub looking like this:
>
> {1, 2, 3, 4, 111, 12.02, 189.119, 8, 9}
>
> System.arraycopy(rub,3,dub,4,3); //Copy 3 elements from rub starting at index 3 into dub starting at index 4.
>
> double[] zz, top = {12.1, 13.1, 14.1, 15.1, 18};[/font]
>
> zz = top;
>
> zz[2] = 99;
>
> top[3] = 100.2;
>
> Show what “both” arrays would look like at the completion of the above code.
>
> zz and top = {12.1,13.1,99,100.2,18}; //Since arrays are actually object references, so setting zz to top results in a reference.
>
> char[] a, b;[/font]
>
> a = “Groovy dude”.toCharArray( );
>
> b = “I like this”.toCharArray( );
>
> System.arraycopy(a, 1, b, 0, 4);
>
> What do the two arrays look like at the completion of this code?
>
> a = {G,r,o,o,v,y, ,d,u,d,e}
>
> b = {r,o,o,v,k,e, ,t,h,i,s}
>
> //Copies "roov" from Groovy into array b.
>
> Assume the array myArray in #12 has been correctly sorted. What would be printed with
>
> the following?
>
> System.out.println( Arrays.binarySearch(myArray, 56) );
>
> System.out.println( Arrays.binarySearch(myArray, 102) );
>
> Where is #12?
>
> What does the following print?
>
> int xc[] = {123, 97, -102, 17};[/font]
>
> int pk[] = {123, 79, -102, 17};[/font]
>
> int gs[] = {123, 97, -102, 17};[/font]
>
> System.out.println( Arrays.equals(xc, pk) + “\n” + Arrays.equals(xc, gs));
>
> false, true
>
> Since the _contents_ of the array xc != pk, and the contents of xc and gs are the same.
>
> Thanks for the answers man but i want to know the code i should use to make this work!
>
> int pickle[] = {1, 2, 3, 4, 5, 6, 7, 8};
>
> Arrays.fill(pickle, -1);
>
> System.out.println( pickle[4] );
>
> Please can you write out the Full code including the class and the static void main, i cant get it to work :/
Link to comment
Share on other sites

> Thanks for the answers man but i want to know the code i should use to make this work!
>
> int pickle[] = {1, 2, 3, 4, 5, 6, 7, 8};
>
> Arrays.fill(pickle, -1);
>
> System.out.println( pickle[4] );
>
> Please can you write out the Full code including the class and the static void main, i cant get it to work :/

You aren't going to learn anything by copying and pasting someone else's work.
Link to comment
Share on other sites

Theres a big difference between help and just flat out doing it all for you. 314piwm gave you all of the code you need for those questions. You really should be able to create the files on your own…. This is clearly school work based on the questions and how they are layed out and you should already know how to setup the basics for classes and the main void....
Link to comment
Share on other sites

Bubble sort ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)

I just wanted to say that *Snicker*

You should really be researching these problems yourself, you will never learn anything having someone spoon feed this stuff to you.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...