Kajamaz Posted November 2, 2012 Author Share Posted November 2, 2012 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 withthe 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 More sharing options...
westin444 Posted November 2, 2012 Share Posted November 2, 2012 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 withthe 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, trueSince the _contents_ of the array xc != pk, and the contents of xc and gs are the same. Link to comment Share on other sites More sharing options...
Guest Posted November 3, 2012 Share Posted November 3, 2012 Cheating on Homework are we? hahaha jk mate! Link to comment Share on other sites More sharing options...
Mal Posted November 3, 2012 Share Posted November 3, 2012 > Cheating on Homework are we? hahaha jk mate!That's why I didn't reply. Every question he gave is solvable without writing a single line of code in an IDE. Link to comment Share on other sites More sharing options...
Kajamaz Posted November 5, 2012 Author Share Posted November 5, 2012 > 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 More sharing options...
Mal Posted November 5, 2012 Share Posted November 5, 2012 > 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 More sharing options...
Ertzel Posted November 5, 2012 Share Posted November 5, 2012 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 More sharing options...
Kajamaz Posted November 5, 2012 Author Share Posted November 5, 2012 Im Asking you to help me and simply show me an example of that code working , the entire code… If i know with that example i can do the rest on my own :/ Link to comment Share on other sites More sharing options...
Ertzel Posted November 5, 2012 Share Posted November 5, 2012 ```import java.util.*;public class ClassName { public static void main(String[] args) { int pickle[] = {1, 2, 3, 4, 5, 6, 7, 8}; Arrays.fill(pickle, -1); System.out.println( pickle[4] ); }}``` Link to comment Share on other sites More sharing options...
Kajamaz Posted November 6, 2012 Author Share Posted November 6, 2012 OMG thats exactly what i had but i mispelled something in my code so it fked up :/It was driving me nuts…Thanks... Link to comment Share on other sites More sharing options...
JohnPony Posted November 11, 2012 Share Posted November 11, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now