Shashank Agarwal

Ranch Hand
+ Follow
since May 20, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shashank Agarwal

Dynamic data is something that is not defined from the beginning. For example, if you wrote a program that calculates peoples age from their date of birth, then the date of birth is dynamic because you cannot tell what the dob is going to be when you code. But, for example, if you say that a day has 24 hours, then that's not dynamic because you can code that in, and it wouldn't change.
10 years ago

Manish Ramrakhiani wrote:Hello All,

I have the following problem with Runtime.exec().



Now, my requirement is :
Inside RunFile.cmd I want to execute another file whose path is given by user.

So I need to pass an argument of the path of file selected by user to this RunFile.cmd.

Please help how can i achieve this.


Thanks,
Manish Ramrakhiani



Something like this (assuming that this is in main)


10 years ago
I'm a little confused. It seems that your compareTo is already sorting it by price, not name.
10 years ago

Ernest Friedman-Hill wrote:Hi Mike --

I did a little Googling on this. It's apparently a COBOL thing. It's a way that signed numbers were stored on tape from COBOL. It seems like it was ad-hoc in nature; I don't think there was a standard format, but it's more of a concept with many implementations. Perhaps something you do when you're storing numbers as BCD rather than binary? Maybe it's older than one's complement? Can't be.



It's a weird name they chose though "signed".
10 years ago

chihwah li wrote:Is there any reason why signed numerics are used?
Signed numeric:http://www.ucop.edu/irc/campus_specs/cgx/signed_num.html
Why use the last digit of a number to determine if a number is positive or negative?

Is there a story from previous Java version or programming problems that signed numerics was invented or used?

Thanks!



For the same number of bytes, you can access bigger (positive) numbers, if you know for sure that you'll have positive numbers assigned to that variable.
10 years ago

Dharmakumar Gajendran wrote:Can any please explain what is Enum and its usage?

Thanks.



Enum helps you enumerate things, like say that days in a week, countries in the world etc. A good tutorial can be found here - http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html
10 years ago
How are you generating i? If it is generated randomly, it needs to be modded (using %) to fall within 0 and 2 (actually, 0 and length-of-vector - 1).
10 years ago
I guess the problem is in line 44 inventoryItem[scan], although you might first want to ensure that all lines are read properly, as suggested by the other poster.
10 years ago
Hey guys, found a fix! Inserted this line after line 04.

parser.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, false);

2.5 hours well wasted!
11 years ago
Hi, I was trying to parse this file - http://www.pubmedcentral.nih.gov/oai/oai.cgi?verb=GetRecord&metadataPrefix=pmc&identifier=oai:pubmedcentral.nih.gov:32301 - using the following code -



Here, at "section nodes," I expect an output of 1, because there is one node in the xml that starts with "article." Instead, I have been getting 0. So I downloaded the file and tweaked around a little, and found that when I get rid of the xmlns=".." declaration in tags "OAI-PMH" and "article," the parser runs fine.

Is there any way of turning off the namespace awareness? Or is there any way the code can be modified to fix the problem? Thanks a lot for any help.
11 years ago
Great. That's what I wanted. Using Apache Derby.
Thanks for the replies. Java DB sounds good. Would it have to be installed on user computer?
The compiler is not able to figure out what QuizCard is. You'd have to import it...
11 years ago

Nrapendra Sharma wrote:i need to detect country mainly.
is there any standard implementation which can be refered for creating a phone parser ..??


I think you could use a list of dialing codes - http://en.wikipedia.org/wiki/List_of_country_calling_codes

See how the codes are not overlapping. eg. if Egypt is +20, there's no country with +20x

So you could put these codes in a map (code -> country), then check the first digit. If that matches a code, then that's the country. If it does not, take the second digit to get a two digit code and see if that's in the map. I don't think that's most elegant, but maybe better than getting a list of regular expressions if all you're trying to do is detect country.
11 years ago

Ariana Green wrote:OK, more dumb questions...

I'm trying to write code from scratch because quite frankly I can't get anything I pick up online to compile. I need to learn by doing so this seems the best way. I understand the rationale behind methods, constructors etc but I'm struggling to pool it all together: most of the examples I read are just code snippets that obviously won't execute, and the things I find online to try are dubious but I can't work out why (100 errors for a 5 line bit of code!? and this from a consultancy site... it must be ME making the mistake, right??). So anyway...

I start with declaring the public class, then the public static void main stuff (is that required?), then I get a bit stuck. If I want to write a class that iterates through a loop until the conditions are met, how do I declare it? Do I set the variables before I type the method? Do I need a constructor, and if so, what exactly do I need to construct? And so forth.

In my head it's all got very muddled and complicated...

I *thought* I understood it fine until I actually started to write the stuff! (Yes, I know. Don't shout at me, at least I'm trying...)



You're doing much better than when I started. Okay, you're getting the idea of writing Java code indeed. the 'public static main' stuff is required indeed. When you run the program, that's where the Java Virtual Machine starts from. Otherwise, if you've got a bunch of methods, how would it know what it should execute first.

>>> If I want to write a class that iterates through a loop until the conditions are met, how do I declare it?
You probably meant a function (or method) to make all conditions meet? You could have

Unless == Not if
Until == Not while

>>> Do I set the variables before I type the method?
Not necessarily. You only need to set local variables before you use them in your method.

>>> Do I need a constructor, and if so, what exactly do I need to construct?
Nope. Usually constructors are used to initialize class variables. You don't need to declare one. The compiler creates a default constructor for you.
11 years ago