comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * execution speed java vs. C - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e8713e999b13b7d1 * Scrollable JPanel having GridLayout. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1b22abc8446a6dd0 * Packing Resource-Based App Into a .JAR - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/39775d78b3d83799 * Can Java Programmer Learn C++ Quickly? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec * Language Q: widening and narrowing conversions and casting - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7d457f06bf9de5ff * Very slow audio performance in JDK 1.5 - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/238f12b544a7d0bb * Java program is not evaluating String value correctly... - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d457b2bb465740e * Simple problem - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/78e14eea63ba6eea * Where do they go? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/13296f4262fb9757 * plugin & packages - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5f8770143f9f32c9 * interface design question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d83b38c5dae9f704 * [Job-SF, CA] Web Framework Architect & Engineer - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1c596c62c43a5159 * Add bytes - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8dcbf5d8bfd2f823 * Efficient way of dynamically invoking a method that returns a primitive type? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7bcb9be06f3aeec1 * Another simple problem - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f3052e16ead05747 * "static" prefix - to parallel "this" prefix - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f5dde10882ac2157 ============================================================================== TOPIC: execution speed java vs. C http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e8713e999b13b7d1 ============================================================================== == 1 of 2 == Date: Thurs, Dec 9 2004 12:37 pm From: [EMAIL PROTECTED] Chris Uppal wrote: > Michael Borgwardt wrote: > Bottom line, I suppose is (insofar as this test is representative): > 1) it would appear that java -server /can/ be as fast as well-optimised C. > 2) using 1-dimensional arrays /can/ be a big win, but only if everything else > is optimised (e.g. by running -server) to the extent where the array access is > in fact the bottleneck. Thanks for that extensive reply. That's very interesting. It occured to me that there might then also be a, possibly large, platform specific component to the runtime result, since it depends on the quality of the runtime engine and how well it translates bytecode into native code. When I changed the two-dimensional arrays into one-dimensional ones though, the runtimes changed to C (-O3): 9.5s java (-server): 11.5s In this form the Java code then is basically comparable in performance to the C code. nick == 2 of 2 == Date: Thurs, Dec 9 2004 1:09 pm From: James Kanze Skip wrote: >>So I went ahead and wrote a very simple matrix multiplication program >>in C and Java and benchmarked them. To my disappointment, C turned out >>to be about 1.5 to 2 times faster than Java. >>int a [][] = new int [N][M]; >>int b [][] = new int [N][M]; >>int c [][] = new int [N][M]; > In java every array is a separate object, if you do: >>int a [] = new int [N*M]; >>int b [] = new int [N*M]; >>int c [] = new int [N*M]; > your code will be a LOT faster. But more difficult to maintain. > further: you benchmark only the first run it seems. the HotSpot JIT seems to > optimize the code only after the same code block is run a couple of times > (normally the 2nd time). A lot depends on the implementation. I noticed that at least on some implementations, the first pass through every function was strictly interpreted -- and at least in his C example, everything was in main. Putting the actual matrix operations in a separate function, and calling it a lot, could easily speed up the Java by a factor of 10 or more. He also said he was running on a Power PC: Mac or AIX, I suppose. Different implementations of Java have more or less advanced technologies. For obvious market reasons, the Windows implementations are the leading edge; Solaris and (I think) Linux comes next, and the rest follows as it can. Still, IBM's support for Java should ensure reasonable quality on an AIX -- maybe with Jikes instead of JDK? -- James Kanze home: www.gabi-soft.fr Conseils en informatique orientée objet/ Beratung in objektorientierter Datenverarbeitung 9 pl. Pierre Sémard, 78210 St.-Cyr-l'École, France +33 (0)1 30 23 00 34 ============================================================================== TOPIC: Scrollable JPanel having GridLayout. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1b22abc8446a6dd0 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 1:19 pm From: "sanjay manohar" Your problem is that GridLayouts always try and shrink to the size of their container. The solution is to create _another_ panel in the hierarchy, that contains the gridlayout panel, but is the View of the scrollpane. this new panel should have a flowlayout, which instructs the gridlayout panel to take up as much space as it needs. ============================================================================== TOPIC: Packing Resource-Based App Into a .JAR http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/39775d78b3d83799 ============================================================================== == 1 of 3 == Date: Thurs, Dec 9 2004 1:04 pm From: "Steve W. Jackson" In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: >:In the package java.util.jar, there is a class called JarFile. You can >:create a JarFile using the name that you eventually choose for the jar. >:In JarFile there is a method called entries() that gives you an >:Enumeration of the elements in your .jar file. Once you have the name >:of the file you want within your .jar file, you can use the URL >:"jar:file:filename.jar!/" in order to load a text file from within the >:.jar. The URL class contains the method openStream() which produces an >:InputStream. You can wrap an InputStreamReader around that and a >:BufferedReader around the InputStreamReader. Then you can read from it >:like you would from a text file. Here's what I think might be a simpler alternative, and it works equally well before and after making a jar of the app. We use this technique most often with images, but it's also used to load files of other types. If my pics are in com/acme/images, you can say: ImageIcon icon = new ImageIcon(this.getClass().getResource( "/com/acme/images/picfile.jpg")) And I've got an ImageIcon from the file, whether it's in a jar or not. In other cases, a class wanting access to a file of any kind can get it as an InputStream: InputStream is = this.getClass().getResourceAsStream( "/com/acme/datafiles/filename.dat"); I can do lots of things with an InputStream to get at the file's contents. = Steve = -- Steve W. Jackson Montgomery, Alabama == 2 of 3 == Date: Thurs, Dec 9 2004 12:50 pm From: "sanjay manohar" In your class DataReader, you could try using Class.getResourceAsStream() rather than FileInputStream? This searches within the current package rather than the current working directory, and works whether or not you are in a JAR file. == 3 of 3 == Date: Thurs, Dec 9 2004 1:04 pm From: Andrew Thompson On Thu, 09 Dec 2004 04:36:22 GMT, cppaddict wrote: > ...java should search for the data files relative to > the .jar root, rather than relative to the root where the process was > started. > > How can I do this? <http://www.physci.org/codes/javafaq.jsp#path> HTH -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ============================================================================== TOPIC: Can Java Programmer Learn C++ Quickly? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 12:59 pm From: James Kanze Ian T wrote: > James Kanze wrote: >> Ian T wrote: >> > James Kanze wrote: >> >> I've never found memory management to be a great problem in C++. And in >> >> the doubtful cases, you use some sort of smart pointer. >> > Right, but it's not something a Java (or VB) programmer would have >> > thought about. So for you it's no problem, but the OP asked the question >> > from the point of view of someone learning the language. >> I'd argue that this isn't true if he has been writing good Java. >> Garbage collection no, you do have to think about lifetime of object >> issues at the design level, as part of the design. > It's not so much the lifetime of the object, but the ambiguity as to > where an object may end its life. For most objects, there is no > ambiguity, but occaisonally there is. In those cases, the garbage > collector acts as a safety net, but in C++ you don't get that. Not only. Garbage collection is IMHO more than just a safety net. There are a lot of cases where having done the design, it becomes apparent that the exact end of lifetime isn't important. You have to do the design, to know this, but once you know it, if you have garbage collection, your work is done. Whereas in C++... >> A bit of extra work, but not something >> >> difficult to get your head around. >> > No so much difficult as unforgiving. >> If you mean that a small mistake can do a lot of damage...:-) > I mean that you may have one tiny, almost unnoticeable memory leak in an > application that runs as a 'daemon' or 'service', and the application is > expected to run continously, so 3 months down the track it can take the > whole server down when it uses up the entire heap. Not that it's ever > happened to me of course ;), but it's an extra level of long term risk > that the garbage collector can mitigate somewhat. Curiously, I've had more problems with memory leaks in Java than in C++. There's a psychological aspect at work -- in Java, you don't give it a thought, so you slip up and forget for that JButton to deregister somewhere. (Especially easy since the designers of Swing slipped up, and forgot to inform the JButton that the window was being disposed.) Whereas in C++, you know its a problem, and you make double sure that all of your memory gets freed. Sometimes before your done with it, of course, but that's another problem:-). Just a fancy way of saying that in practice, I've seen more problems with dangling pointers in C++ than with memory leaks. (And one of my C++ applications runs 24 hours a day, 7 days a week, with contractual penalties over something like 5000 Euro per minute for downtime.) [...] >> Sorry. Today, of course, std::string is pretty much standard. I don't >> know of a compiler which doesn't support it, and I don't know of any new >> code which doesn't use it. > Right. I use std::string, but there is still a huge codebase out there > (which someone has to support for the next 10-20 years) that uses > null-terminated character arrays, including the Win32 API. It's true that C++ often interfaces directly to C level API's. And of course, you have to use null terminated strings there. But that use is generally limited to the interface level itself. > And of course > the std::string implementation uses ntcas as well. Not at all. The exact details vary from one implementation to the next, but the basics are often fairly similar to the implementation of java.lang.String. > I'm not at my development computer, but just doing a search through some > of the open source C++ code I've downloaded reveals that there are still > plenty of people who have not moved entirely to std::string. Looking at the open source code I've got on my machine... I find it hard to find any C++ at all. All of Linux is in C, for example. As is g++ -- it compiles C++, but was written in pure C. And of course, in C, you don't have any real alternatives. >> Think of it from a Java point of view. If the language didn't provide >> java.lang.String, would you really use Char[] with a '\0' terminator? >> Or would you write your own String class? > I'm trying to imagine how I would create my own string class without > using null terminated character arrays. Use std::string? The sources of java.lang.String are available somewhere. My pre-standard String class (dating from 1991) looked almost exactly like it -- the main difference was that I used reference counting for garbage collection, and I supported value semantics (but the only way to modify a String originally was assignment -- I had a StringBuilder class which worked a lot like StringBuffer). >> > Yep, second the Meyer's book. >> It's the Meyers' books. > Those damn apostrophes!!!!! Actually, the error I was picking on was "book" instead of "books". >> "Effective C++" and "More Effective C++" for the >> language, and "Effective STL" for the library. > I have 1 and 2, what's "Effective STL" like? It's probably the best practical book on the STL that I've seen. Like the other books, it supposes some previous knowledge of the basics, then goes on to point out all of the things you really have to pay attention to. Still, if I had my choice, I'd be using the OSE or my own library, rather than the STL. -- James Kanze home: www.gabi-soft.fr Conseils en informatique orientée objet/ Beratung in objektorientierter Datenverarbeitung 9 pl. Pierre Sémard, 78210 St.-Cyr-l'École, France +33 (0)1 30 23 00 34 ============================================================================== TOPIC: Language Q: widening and narrowing conversions and casting http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7d457f06bf9de5ff ============================================================================== == 1 of 2 == Date: Thurs, Dec 9 2004 12:51 pm From: Eric Sosman jeffc wrote: > Reading Mughal "Programmer's Guide to Java Certification". It talks about > widening and narrowing conversions of primitive data types. Widening is OK > (e.g. int to float). Narrowing causes loss of information. This makes sense. > > Now the confusing part, wrt reference types. It also calls upcasting a > widening > conversion, and downcasting a narrowing conversion. This makes sense from the > perspective that going up the class hierarchy is usually fine, but going down > is > usually not. What doesn't make sense is the "widening/narrowing" terminology, > and the loss of information. You are actually widening going down the > hierarchy, in terms of data size. You are also losing information, in a > sense, > by going up the hierarchy. (After upcasting, you no longer have access to the > class extensions, so your object is effectively smaller, not larger. > > Comments? Comment: IMHO, "widening" and "narrowing" are the terms at fault. They do not even describe conversion between primitive types correctly -- for example, both int-to-float and float-to-int can lose information, so which type should be called "wider?" When this already sloppy terminology is applied to reference variables, it loses what little sense it had in the first place. Don't waste time trying to stuff sense back into it. -- [EMAIL PROTECTED] == 2 of 2 == Date: Thurs, Dec 9 2004 12:06 pm From: "jeffc" Reading Mughal "Programmer's Guide to Java Certification". It talks about widening and narrowing conversions of primitive data types. Widening is OK (e.g. int to float). Narrowing causes loss of information. This makes sense. Now the confusing part, wrt reference types. It also calls upcasting a widening conversion, and downcasting a narrowing conversion. This makes sense from the perspective that going up the class hierarchy is usually fine, but going down is usually not. What doesn't make sense is the "widening/narrowing" terminology, and the loss of information. You are actually widening going down the hierarchy, in terms of data size. You are also losing information, in a sense, by going up the hierarchy. (After upcasting, you no longer have access to the class extensions, so your object is effectively smaller, not larger. Comments? ============================================================================== TOPIC: Very slow audio performance in JDK 1.5 http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/238f12b544a7d0bb ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 1:30 pm From: "Pansje" Hi all, An application which uses sample audio runs well in JDK 1.4 but it seems that JDK 1.5 can't cope with the needed speed. ( gaps and other disturbances in audio-playback) Is this a known issue? I reverted to JDK 1.4, but I'd love to use those new language extensions of JKD 1.5 Cheers, Hans ============================================================================== TOPIC: Java program is not evaluating String value correctly... http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d457b2bb465740e ============================================================================== == 1 of 2 == Date: Thurs, Dec 9 2004 1:20 pm From: [EMAIL PROTECTED] I believe your problem has to do with the use of ==. When used between object references, == returns a boolean indicating whether or not the two references point to the same object. == between String literals does test equality, but because there is only one copy of a String literal maintained in memory. For testing equality between Strings, it's best to use .equals == 2 of 2 == Date: Thurs, Dec 9 2004 1:09 pm From: "Steve W. Jackson" In article <[EMAIL PROTECTED]>, "Shelly" <[EMAIL PROTECTED]> wrote: >:I have code where I get a string value from a file which contains the >:State Abbreviation and compare it for state specific programming. >: >:When it wasn't falling through the correct code, I put statements in to >:prompt and tell me what was coming back in that field before it hit the >:condition. The weird thing is, is that it is correct (no extra >:spaces--nothing), but it doesn't like it. For further troubleshooting >:purposes I set the field to what I wanted right before the condition >:and then it works. The way I'm filling the state abbreviation string >:(via a cell in an Excel Spreadsheet) is being used throughout the >:program for other variable strings as well and is working just fine. >: >:Here is the code... >:*********************************************************************** >:** The ini.stateAbbr when checked here is WI no spaces or extra chars * >:** But it goes to the "else" of this first condition. * >:** Even if you can tell me other things to check would be great * >:** because I'm looking at brick wall here. * >:*********************************************************************** >: >:if (ini.stateAbbr == "WI") { Above is the source of your error. To compare a String variable to a String value, use .equals() instead, so it becomes: if (ini.stateAbbr.equals("WI")) { >:if (groupToPrint.masterNumber == "0") { >:usablePath = groupToPrint.eMailAddress.trim() >:+ " " >:+ groupToPrint.stringGrNo >:+ groupToPrint.masterNumber >:+ groupToPrint.locNumber >:+ groupToPrint.subNumber >:+ groupToPrint.poolNumber >:+ " " >:+ groupToPrint.descriptiveName >:+ theDate >:+ theTime; >:} else { >:usablePath = groupToPrint.eMailAddress.trim() >:+ " " >:+ groupToPrint.masterNumber >:+ groupToPrint.stringGrNo >:+ groupToPrint.locNumber >:+ groupToPrint.subNumber >:+ groupToPrint.poolNumber >:+ " " >:+ groupToPrint.descriptiveName >:+ theDate >:+ theTime; >:} >:} else { >:if (groupToPrint.masterNumber == "0") { >:usablePath = groupToPrint.stringGrNo >:+ groupToPrint.masterNumber >:+ groupToPrint.locNumber >:+ groupToPrint.subNumber >:+ groupToPrint.poolNumber >:+ groupToPrint.timePeriod >:+ groupToPrint.descriptiveName >:+ theDate >:+ theTime; >:} else { >:usablePath = groupToPrint.masterNumber >:+ groupToPrint.stringGrNo >:+ groupToPrint.locNumber >:+ groupToPrint.subNumber >:+ groupToPrint.poolNumber >:+ groupToPrint.timePeriod >:+ groupToPrint.descriptiveName >:+ theDate >: + theTime; >: } >:} And the same for all other uses of == to String literals... = Steve = -- Steve W. Jackson Montgomery, Alabama ============================================================================== TOPIC: Simple problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/78e14eea63ba6eea ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 12:02 pm From: Michael Borgwardt Paul van Rossem wrote: > 1) The class declaration can't have a parameter. Sure they can - a type parameter: class SomeClass<Parameter>{} ============================================================================== TOPIC: Where do they go? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/13296f4262fb9757 ============================================================================== == 1 of 3 == Date: Thurs, Dec 9 2004 1:07 pm From: Andy Hill "2471" <[EMAIL PROTECTED]> wrote: >I have just started programing and have started with java. It seems to >be going pretty good, but i have a question that i can not find an >answer to. When creating a data structure such as a linked list, i am >not sure how to remove a node. I mean i know how to make nothing point >to it so it is no longer in the linked list but how do i go about >removing it. The problem seems rather unimportant when using a small >sample size, but if say my linked list had 1,000,000 nodes and i remove >500,000, it seems like a waste of computer memory to just have those >500,000 nodes just hanging around with nothing pointing to them. > Um, that's what the garbage collector is for. == 2 of 3 == Date: Thurs, Dec 9 2004 1:16 pm From: "Steve W. Jackson" In article <[EMAIL PROTECTED]>, Andy Hill <[EMAIL PROTECTED]> wrote: >:"2471" <[EMAIL PROTECTED]> wrote: >:>I have just started programing and have started with java. It seems to >:>be going pretty good, but i have a question that i can not find an >:>answer to. When creating a data structure such as a linked list, i am >:>not sure how to remove a node. I mean i know how to make nothing point >:>to it so it is no longer in the linked list but how do i go about >:>removing it. The problem seems rather unimportant when using a small >:>sample size, but if say my linked list had 1,000,000 nodes and i remove >:>500,000, it seems like a waste of computer memory to just have those >:>500,000 nodes just hanging around with nothing pointing to them. >:> >:Um, that's what the garbage collector is for. Yep. And it might be worth looking into java.util.LinkedList for grins. = Steve = -- Steve W. Jackson Montgomery, Alabama == 3 of 3 == Date: Thurs, Dec 9 2004 12:55 pm From: "2471" I have just started programing and have started with java. It seems to be going pretty good, but i have a question that i can not find an answer to. When creating a data structure such as a linked list, i am not sure how to remove a node. I mean i know how to make nothing point to it so it is no longer in the linked list but how do i go about removing it. The problem seems rather unimportant when using a small sample size, but if say my linked list had 1,000,000 nodes and i remove 500,000, it seems like a waste of computer memory to just have those 500,000 nodes just hanging around with nothing pointing to them. ============================================================================== TOPIC: plugin & packages http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5f8770143f9f32c9 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 12:06 pm From: Chris Smith VisionSet <[EMAIL PROTECTED]> wrote: > It is a very simple demo app, I've got it working with the class files, and > I'm happy with it. The directory is scanned for class files and a > Class.forName gets the class, if it is not assignable to my Inteface it is > rejected. There is only one simple class implementation required. If it > were more elaborate I'd go for jars. Just please don't deploy this, then. Sounds like you're making things harder than you need to (for example, you're loading the classes with Class.forName? Does that mean that you're placing these plugin classes in the classpath?) while simultaneously preventing people from using good programming techniques. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation ============================================================================== TOPIC: interface design question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d83b38c5dae9f704 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 12:16 pm From: "sanjay manohar" Exactly. And note that you dont need to call super() if you have no arguments. ============================================================================== TOPIC: [Job-SF, CA] Web Framework Architect & Engineer http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1c596c62c43a5159 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 1:11 pm From: "hiTECH.RECRUIT" Hi all, Our client is a leading enterprise software company in San Francisco - App Server/Application Development & Devployment Platform. They're currently growing their Technical team, and would like to hear from all of you talented engineers out there. Below is a description of the opportunity. To express interest, please contact/send resume to [EMAIL PROTECTED] --Web Framework Architect & Engineer-- Location: San Francisco, CA Our client's solutions empower enterprise developers to rapidly create composite, event-driven applications that inherently deploy to horizontally scaled, commodity computing environments. Responsibilities: " Create a new declarative web framework based on emerging XML standards. " Integrate with and Define requirements for tools and database libraries. " Support rich client capabilities such as DHTML. Requirements: " Motivated and stellar coder. " 5-10 years experience in the areas described. " Infrastructure software (BEA, IBM WebSphere, Borland, etc.) and non-dotcom startup experience. " Experience creating web frameworks such as JSF, Cocoon, WebWare, etc. ============================================================================== TOPIC: Add bytes http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8dcbf5d8bfd2f823 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 12:21 pm From: "Stefan Schulz" On 9 Dec 2004 11:42:59 -0800, Fran Garcia <[EMAIL PROTECTED]> wrote: > I´m trying to do a concatenator of wav files and I´ve the next > problem: The wav files have a header with 44 bytes and the bytes from > 40 to 43 represents the length of the wav samples. Now, I want to add > this portion of header of two files but I don´t know how to do it. Can > anybody help me? > > |0|1|2|........|40|41|42|43| --> wav file1 > |0|1|2|........|40|41|42|43| --> wav file2 > ------------------------------------------------------------------- > |0|1|2|........|40|41|42|43| --> wav union Get the represented number: int l1 = x[40] << 24 | x[41] << 16 | x[42] << 8 | x[43] int l2 = y[40] << 24 | y[41] << 16 | y[42] << 8 | y[43] add them int newl = l1 + l2 put it bytewise in your output header. byte [] outbytes = { newl & 0xFF000000 >> 24, newl & 0xFF0000 >> 16, newl & 0xFF00 >> 8, newl & 0xFF} -- Whom the gods wish to destroy they first call promising. ============================================================================== TOPIC: Efficient way of dynamically invoking a method that returns a primitive type? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7bcb9be06f3aeec1 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 1:02 pm From: "sanjay manohar" I suppose you have a very good reason why the client application does not know the NAME of the method until runtime? smells like a bad versioning problem... There is Almost always a way to know the name of the method at compile time. that is, assuming that you are writing both the client and server software... ============================================================================== TOPIC: Another simple problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f3052e16ead05747 ============================================================================== == 1 of 3 == Date: Thurs, Dec 9 2004 1:36 pm From: [EMAIL PROTECTED] The constructor name has to be the same as the class name. == 2 of 3 == Date: Thurs, Dec 9 2004 1:29 pm From: "Stefan Schulz" On Thu, 9 Dec 2004 21:57:25 +0100, stud <[EMAIL PROTECTED]> wrote: > ERROR: > invalid method declaration; return type required > invalid method declaration; return type required > > what's wrong here? > > class insertFailException extends SQLException > { > public insertFailedException(String reason) > { > super (reason); > } > public insertFailedException() > { > super(); > } > } Compare your Constructor Names to the name of the class... Also, usually class names start with an Uppercase letter. -- Whom the gods wish to destroy they first call promising. == 3 of 3 == Date: Thurs, Dec 9 2004 1:31 pm From: Andrew Thompson On Thu, 9 Dec 2004 21:57:25 +0100, stud wrote: > Sub: Another simple problem Simple problems are best dealt with on a different group. <http://www.physci.org/codes/javafaq.jsp#cljh> > ERROR: > invalid method declaration; return type required > invalid method declaration; return type required > > what's wrong here? For resolving problems, start here. <http://www.physci.org/codes/javafaq.jsp#exact> > class insertFailException extends SQLException > { > public insertFailedException(String reason) This is because you failed to follow-up on the advice that Paul van Rossem (and possibly others) pointed out in your 'Simple Problem' thread. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ============================================================================== TOPIC: "static" prefix - to parallel "this" prefix http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f5dde10882ac2157 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 1:25 pm From: Tim Tyler Darryl L. Pierce <[EMAIL PROTECTED]> wrote or quoted: > Tim Tyler wrote: > >>>Most of the uses of the classname are redundant. To see that, change > >>>the name of the class. All the uses of the classname (within the > >>>body of the class) that have to change with it are redundant. > >> > >>Change the name of an instance variable. All the uses of the variable > >>(within the body of the class if not the clients of the class) that have > >>to change with it are redundant. > > > > Nonsense: they say which variable you are talking about. > > > > Within the definition of a class you shouldn't need to spell out > > the name of the class - you /should/ just be able to say "this class". > > You don't *have* to mention the class *except* to clarify the context, > just as you do when you use the "this" keyword. Constructors are the most common mention of class names in the same class. They replicate the name of the class at several places within the class. The only alternative is not to use constructors - and then you lose out on the inherited constructor from Object - and implicit calls to super(). > >>BTW, the above scenario doesn't happen in Eclipse: you refactor and > >>rename the class and all of those references are updated. *AND* the > >>references in *other* classes are updated too. Which brings up an > >>interesting question: how will you refer to static methods/variables in > >>*other* classes? Are we going to keep the ClassName.staticField pattern? > >>If so, then we now have *two* ways of doing the *exact same thing* which > >>to my mind makes the static keyword even *less* attractive. > > > > Actually there would be three ways: > > > > "ClassName.var" > > "var" > > ....or... > > "static.var". > > > > They don't say quite the same thing as each other - though they > > would all refer to the same static variable. > > And how does the above tell you *which* other class you're referring to? It doesn't. I never said it did. I was just pointing out that the claim that there were *two* ways of doing things was incorrect: Actually two ways is the current situation - so your argument boils down to an assertion that the current situation is undesirable ;-) > I asked above "how will you refer to static methods/variables in *OTHER* > (new emphasis) classes?" The same as normal. The proposal has nothing to do with that. > In this scenario "static" brings nothing new to the table [...] It deals with the situation where you are distingishing instance variables, local variables and static variables in the *same* class. The proposal was never supposed to improve the situation with other classes. It is analogous to "this" in that respect. > and you will *still* have to type the classname to provide > context to the compiler. So, in deference to your claiming it's > redundant data, it's actually quite necessary [...] You should not have to spell out the class name repeatedly in the class. Doing so is redundant - and it's a maintenance screw-up - since you open up the possibility of the names getting out of step. You /should/ be able to say something which says "this class". In a sensible language, you'd just use the class object: "class" - but of course in Java, this doesn't work. -- __________ |im |yler http://timtyler.org/ [EMAIL PROTECTED] Remove lock to reply. ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
