- Strength to Increase Rep
- +4
- Strength to Decrease Rep
- -1
- Upvotes Received
- 6
- Posts with Upvotes
- 6
- Upvoting Members
- 6
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Re: do ls -l /usr/bin/java and ls -l /usr/bin/javac and look at the output. | |
Re: Arrays/Objects ARE accessed using reference variables. Parameters are passed by value in Java, so if you pass an array to a method it is a copy of the reference to the Object or array that is passed not a whole copy of each element in the array. It goes to … | |
Re: I assume you are using self signed certificates. Is your friend using a proper signed certificate? | |
Re: A contiguous sequence of memory? | |
Re: Looks like you are learning the hard way parallel programming. MPI has all the tools to do this relatively painlessly. Doing it the hard way I guess: create original array containing all the data and two other arrays half the size, create your two sub processes, each subprocess sorts one … | |
Re: well known method: (( 1stNumber + 2ndNumber ) * numberOfNumbers) / 2 eg. 1st Number = 4 2nd = number 8 ( ( 4 + 8 ) * ( 8 - 4 + 1 ) ) / 2 ( 12 * 5 ) / 2 = 30 | |
Re: The default .hashCode() method uses the contents of the string to create the hashcode so unsuprisingly all the values are the same. A better test is: [code] String str1="ABC"; String str2="ABC"; String str3 = new String("ABC"); if( str1 == str2 ) System.out.println( "str1 and str2 reference same object"); else System.out.println( … | |
Re: Just out of interest, here is a recursive method ( which I don't claim to have rigorously tested by any means) [CODE] public static int sumPowers( int n, int m ) { if( m > 0 ) { int sum = n; sum *= sumPowers( n, --m ); return sum+1; … | |
Re: ...as has been pointed out double is different from Double, double is a primitive type, Double is an immutable object, arraylists and other such collections can only accept objects. If using an array is appropriate for the situation then go ahead and use it, if a dynamic data structure such … | |
Re: Big problem I've seen at universities/colleges compared to back then is students expecting the "teaching" of a subject to be only within the bounds of what is actually delivered within class rather than what is delivered in class being a basis for reasearching and learning on your own. My opinion … | |
Re: You have a text file. It is split into lines. You are reading it a line at a time. Read a line and if it starts with S and 2 then ignore it. String.startswith() or something like that. Lookup String class. | |
Re: a) 2 power 24 - 1 b) well BCD 4 bits each digit 0-9, work it out, 21 - 0010 0001 c) a bit of a trick question, ACII is used to represent characters not numbers specifically but you can look up the ASCII table and fiddle about but I'd … | |
Re: Taking what you've said without any further constraints then interpret it as a poistive base two number, convert it to decimal and that is that. | |
Re: Yup local variable is getting created. You're not actually modifying anything - java everything is passed by value, a copy is made. So a copy of whatever reference value bytes[] holds is getting made, in this case null and assigned to the local variable bytes in your function. You have … | |
Re: [code]if(numList.get(i) == numList.get(j))[/code] You are actually comparing if two Integer objects are referencing the same object. Try numList.get(i).intValue() == numList.get(j).intValue() Couldn't say for sure why the way you are doing it works in some cases. | |
Re: You have to provide a lower aswell as an upper bound or your expression will return true at the first match e.g //Sanitize salesPersonName first salesPersonName.matches( "[a-zA-Z]{20,20}"); As a tip, it's redundant to be doing the test twice in your code, use a normal while loop rather than do/while. | |
Re: Have a look at the Sun JavaCompiler class, haven't used it myself. | |
Re: Just use one pass of the bubble sort algorithm as hinted at in the code in previous post. The larget value in the array will be in the last position of the array after one pass, the second largest in second last position after two passes etc.. | |
Re: And another variation where index is initially the length of the String: [code] public String reverse(String s, int index ){ if( index >0 ) { return s.charAt( --index) + reverse( s, index); } return ""; } [/code] | |
Re: Simple answer - sort your small list using an appropriate algorithm then merge them using an appropriate algorithm and of course you can sort a linked list in less than O(n^2). | |
Re: Just my penny's worth - do it if you are genuinely interested in it. Computer Science isn't "all my friends have problems with windows and I fix it for them". Programming is only one area of Computer Science ( all be it important ) and even then, knowing the syntax … | |
Re: [QUOTE]Isn't 10 instances of Animal class is being created with this line?[/QUOTE] Nope, ten uninitialized reference variables of type Animal are being created. | |
Re: Just out of curiosity, what is the overall aim of the program? Are you trying to generate the power set of an array of values and do you have to use Random? At what point will the program have accomplished it's mission? | |
Re: As far as I'm aware applets can't by default write to the local file system: security. Google should show you how to do it. | |
Re: This is one version. You might want to look up Generics as of course, only works with int[] [CODE] private static void mergeSort( int[] data ) { if( data.length > 1 ) { int midPoint = data.length / 2; int[] left = new int[ midPoint ]; int[] right = new … | |
Re: You're not returning maxtemp from the getinput function. | |
Re: I assume it means shifting all the elements one place to the right with the last element in the array wrapping around to be the first element in the array with every rotation. | |
Re: You had the hostname spelling wrong for one thing and your use of Scanner doesn't look right. You program still isn't quite right though. Remember, it's possible to telnet into servers that use "text" format which can help a lot in trouble shooting. [CODE] Socket s = new Socket("time-a.nist.gov", HTTP_PORT); … | |
Re: You're incrementing i in the wrong place. |