verruckt24 438 Posting Shark

I suppose you are allowed to use the String class' methods.
1. For longest & shortest word use length method of String.
2. To split use StringTokenizer class
3. For palindrome make use of the stack ds.
If you cannot use String methods you'll have to traverse the string maintaining a counter until you encounter a termination char like a space, comma, period or newline.

verruckt24 438 Posting Shark

Use regex to check whether a string is made up of alphanumeric characters or only letters then print out the ones you need.

verruckt24 438 Posting Shark

I suppose here, the word interface doesn't mean the Java language type. What it wants to mean is a contract, much like how it is between a library developer and it's user. The word here maps more closely to the method signature. Something like "overidding allows multiple methods to have the exact same signature" so "one interface, multiple methods"

PS: On reading JC's post again, I guess he's trying to say the same thing.

verruckt24 438 Posting Shark

1. Class Cars doesn't have a main method, so how do you'd expect it to run ? If you need to run it put a main method in it which acts as an entry point for a program to run.

2. In the CarsInventory2 class

public double gettotalInventory() ; // remove the semi-colon here
                  {
                           return totalInventory;
                  }
 
                  public double getProdInventory() ; // remove the semi-colon here
                  {
                           return ProdInventory;
                  }

then again

{ // remove this opening brace, thats why you get the class or interface req. error
                           for ( int i = 0; i < myCarArray.length; i++ )
                  {

3. In the CarsInventory class you do not have the closing brace for the class, you have put a closing brace for main thats it.

verruckt24 438 Posting Shark

post your code

Hmm...wasn't that advice already given ?

verruckt24 438 Posting Shark

Firstly to separate out the words in the string, you could use the StringTokenizer class and split the string based on space chars.

Secondly stack is a common data structure used for checking palindromes, so that you push every character from a word into the stack till you are half way through the word then for every char from the word, you pop one out of the stack and compare them. If both are the same you move forward. If in this way you are able to reach the end of the string, you can conclude it is a palindrome.

Note : Special processing is required for strings with odd number o characters, you would have to omit the character in the middle. For e.g. ISI, drop S from being checked, hope you get it.

verruckt24 438 Posting Shark
double price=0.0;
double rate=0.0; 
// other initializations

These are local (method) variables, which are also known as auto variables. And the tricky part is that auto variables are never initialized automatically for you as their name would rather suggest. You need to initialize them before using them, else the compiler complains as you've seen. If these would have been instance/class variables, java would have initialized them to a default for you. For example an int variable from a class is initialized by default to 0, a double to 0, an object reference to null and so on.

verruckt24 438 Posting Shark

but i wanna learn java!

The thread at the top of the forum will only help you in your resolution.

verruckt24 438 Posting Shark

I wish you didn't.

verruckt24 438 Posting Shark

post your code, check with the instanceof operator in java what instance is actually residing in the ExitInterface type variable.

verruckt24 438 Posting Shark

What you could is traverse the entire string, character by character. At each character, check the char and increase it's count. You would have to maintain 26 different counters - one for each letter of the alphabet.
Use the switch-case construct to check the chars. Something like below:

switch(char){
    case 'a' or 'A': {aCtr++; // increase a's counter
          break;} 
    case 'b' or 'B': {bCtr++; // increase b's counter
          break;} 
    // rest of the code...
}
verruckt24 438 Posting Shark

Hey Mr.BestJew you need not tell me to google or not google before posting a thread.......stop giving ur crap suggestions.....its upto me to post the thread or not....

Mr. Mr check your attitude here. Everyone's here to help but it isn't to be taken for granted no one's obliged to help you. Yes you can certainly decide whether you want to post or not, but so can javaAddict and BestJew... whether they want to help or not and mind you they did.

What BJSJC adviced you, was what's considered appropriate. Every forum recommends a poster to search for the information in all places he can and then if he still doesn't get a satisfactory answer advices to post. This way not only is the poster getting the help without delays, but if you still have any questions you will be supposedly having enough background information to frame the question in the right way. In short he means to say that if you can so easily find the information on google you may as well have tried it before posting here and there's nothing to get intimidated by it.

verruckt24 438 Posting Shark

Use functions - will make code readable, maintainable. Draw common and put it at a single place. For example the SOPs could be handled in a function of their own dedicated to display/output instead of writing them so many times. Only the required values need to be accessible to them.

verruckt24 438 Posting Shark

You are creating a ByteArrayInputStream from the byte array 'buffer', which has just been initialized. byte being a primitive type will initialize to it's default value which would be 0 (??). Then you are using this ByteArrayInputStream - baos - to create an ObjectInputStream. The constructor documentation says:

Creates an ObjectInputStream that reads from the specified InputStream. A serialization stream header is read from the stream and verified. This constructor will block until the corresponding ObjectOutputStream has written and flushed the header.
If a security manager is installed, this constructor will check for the "enableSubclassImplementation" SerializablePermission when invoked directly or indirectly by the constructor of a subclass which overrides the ObjectInputStream.readFields or ObjectInputStream.readUnshared methods.

I don't have a clue what the second parts means, but the first part means that the stream should contain a valid serialization header, which as we have seen you aren't obviously setting. Now if these headers are set implicitly then we may be on the wrong track but if they are not then may be you need to do something to the stream before you use it to create the ObjectInputStream.

These are just swags, which hopefully go into the right direction, I may as well be completely wrong.

verruckt24 438 Posting Shark

Alright, no one's come up with help as of now so I proceed forward.

What you could do is move through the entire string character by character, everytime comparing whether current character is greater than the previous one. 'Greater than' means that the character comes later in the alphabet than the previous one. This could be done simply by doing something like this:

seqStr=str.chaAt(i); // add the first character directly to the sorted string sequence.
for(int i=0;i<str.length();i++){
    if (str.charAt(i)<str.charAt(i+1){
        //concat the char at i+1 to the sorted substring sequence
        seqStr+=str.charAt(i+1); 
    }
    if (seqStr.length()>maxSeq){
        maxSeqStr=seqStr;
    }
}

If you work on these lines then by the time you are done traversing the string, you would have your longest sorted substring sequence ready. You would have to add a lot more into this code to get it working, this is just an outline of the critical part.

verruckt24 438 Posting Shark

Google.

verruckt24 438 Posting Shark

Don't judge yourself against the list of buzzwords than some HR grunt pulled out of their grab bag of cheap adjectives. If I compare myself against an ad, I'd be woefully underqualified for my own job

You do not know how comforting those words are for someone currently going through a lot of ads and getting all the more depressed by the time he's done reading it. ;)

verruckt24 438 Posting Shark

Firstly this while loop from the main methodis flawed. It reads into aline till the time that it isn't null, then when finally it gets null it is passed on to the printData method. So what are you gaining from it by passing a null object.

while (aline != null)
{
totalPatients = totalPatients + getTotalPatients(aline);
aline = br.readLine();
}
System.out.println("Printing Data..");
printData(aline);

Secondly you have a similar loop in the printData method where you loop through until the aline object has null in it

while (aline != null)
{
aline = br.readLine();
}

and then when it's null you use it to create a StringTokenizer here

StringTokenizer st = new StringTokenizer(aline);

This will throw a NullPointerException now if you see your code catches an exception but never prints out the trace.

catch (Exception fx)
{
}

So you do not get an output neither an exception trace.

verruckt24 438 Posting Shark

Make sure the jar file is in path. You can also specify the location of the jar file through the "cp" flag.

verruckt24 438 Posting Shark

Every company in the world that hires 'new hires' or college students or anyone just joining the workforce is making an investment based on the hope that the people they hired possess talent of some sort. Presumably most of those people are not well established in their field and many have not ever had a career job before at all.

I agree with you, but while writing the above post I didn't believe that we were really talking about interns/freshers here, cause with freshers there's no other alternative parameter to judge them on apart from the "promise" that they seem to make. While hiring such people an interviewer would filter them based on their education, call the selected ones for interview and then, if he decides to employ them, hope they would be as good as they sounded in the interview i.e hope that they live upto the "promise" they make.

verruckt24 438 Posting Shark

Yes, I missed that one. For MySQL you should be using this driver.

verruckt24 438 Posting Shark

Firstly those are not "bugs", they are plain errors that won't go past the compiler itself. Secondly if he knew them well which I think he should have then he might have had solved the problem himself. Lastly we aren't here to compile & run his programs thats for him to do.
I agree with the fact that Exception traces and error statements are the least a beginner can do to allow us to solve his problems, but if the errors are just too obvious for us then we don't require the extra information and we could just as well point them the issues directly.

verruckt24 438 Posting Shark

You need to add port information in the URL. MySQL's default port is 3306 so unless you have made any changes to it that's whats missing. Try adding the port number after the localhost.
Also sometimes localhost doesn't work so try 127.0.0.1. But this is certainly the problem that I have faced so in your case it might not be.

verruckt24 438 Posting Shark

it's really no point talking to a moron.... trying to get a point over his head. im not saying you depend it all to him.. im just saying that a company dont just hire all pure smart programmers... they can give a chance to average programmmer.... coz. they will grow from work experience. of course u must have a smart lead programmer that will lead the team.

Actually I have to disagree to the point you seem to make here. Allowing a person to grow in experience and knowledge takes time, money and obviously other resources. And while this would be a very humane gesture towards anyone we have to understand that organisations cannot always function in this manner however hard we might want them to. Organisations, as Bruce Eckel indicates in one of his recent blogs will always have monetary considerations uppermost in their minds. And these considerations would always want them to hire individuals well established in their fields, experts as some might like to call them, ready to deliver what they promise from day one (so to speak) so that the organisation can address their primary concern.

Even though we assume that some organisation might even have enough heart to employ a person under the pretext that he might grow with experience, who's ready to pay the cost if he/she doesn't. And this certainly is a high probability that I am talking about considering a lot of people, once comfortably employed with their monthly paycheck would …

verruckt24 438 Posting Shark

What's wrong?

you didn't specified what errors you got while compiling or running..

that is wrong...hi..hi...

If you read all the posts which I do not think you've done, you'll pretty much understand that the problems were compile time, which had been already suggested to him and he might have already been on his way, when you decided to give him a slight tap on his hand for... nothing.

verruckt24 438 Posting Shark

ehm... why? it's an interface, so that code is correct

Yeah actually adatapost cleared it. I was talking about the code from the class Arrangement to which he had already provided a definition.

verruckt24 438 Posting Shark

Apart from the mistake mentioned by the adatapost, here's another:

public void Pitch (String types);

that appears to be a method without definition, remove the semicolon at the end of the line.

kvprajapati commented: Thanks! +6
verruckt24 438 Posting Shark

Nevermind we'll help you solve this problem and by the end of it you'll sure have gone a micro step further. The Regular Expressions Tutorial is one of the best from the Java Tutorials section. Also use the File tutorial to get yourself acquainted with reading/writing files.

Use the Tutorials and the Java API Docs heavily especially since you are a beginner to get yourself rolling. What else will help is writing hundreds of programs.

verruckt24 438 Posting Shark

Not necessary if you are talking about exceptions in general and not the Exception class. Exception classes which extend RuntimeException and Error can be used in the throws clause without forcing the client or the consumer to catch them. This is normally done for documentation purposes but is perfectly legal and common scenario.

Precisely, thats why you are never forced to catch the NullPointerException even if it is thrown.

verruckt24 438 Posting Shark

A project topic should be chosen according to one's interests, especially if you are given the liberty to do so. Programmers don't need to be given a topic they just have this idea in their mind about something that could be. About something that could be done in a better, more improved way and they start working on it and it soon becomes a project.

Ask yourself one question here, how good an engineer/programmer you would be if you are not even able to single out a topic from the vast number of them out there if you aren't able to find out a single one that interests you.

Salem commented: Bravo, well said!!!! +19
verruckt24 438 Posting Shark

For a very high level break down on the records consider them to be following this format:

Name | {Data Number}+ | ["average" {number}1]

Basically, name, followed by one or more occurrences of data numbers, optionally followed by the occurrence of the string "average" along with exactly one numerical value.

Now you could break each of these entries further for example, the entry Name has a format of {a-zA-Z}+." ".{a-zA-Z}+ which is 1 or more occurrences of characters followed by space followed by another 1 or more occurrences of characters. The data numbers entry could be formatted as {{0-9}." "}1 which is one or more occurrences of digits followed by a space character.

You would need to form a regex pattern for all indivuidual entries on a similar basis and then filter out those lines which do not follow this pattern, the lines that follow the pattern will then have to be splitted/tokenized accordingly. The formats provided here are not exactly the regex patterns, those you'll have to work out on your own, but this one of the ways you could sort this.

verruckt24 438 Posting Shark

Do these records have a particular format, are they line separated ? as in one record per line ? If yes then you could read the file line by line and use the appropriate splitting criteria to get individual tokens. If not then you first need to establish a format of your own through which you cold filter the entries. Since in the case that a single record entry could span multiple lines, you have no way to tell the end of record, apart from identifying a string which is not equal to ("average") and assuming it to the name of the next person in which case you could mostly assume that the first record has ended. I say "mostly assume" because this may not necessarily suggest the start of a new record and could may as well be some other chars. Also as you mention the occurrence of the "average" flag is not certain which could have confirmed the end of the previous record.

verruckt24 438 Posting Shark

Thread.currentThread().sleep(1000);//sleep for 1000 ms

Thanks that was particularly helpful, especially because the Java guys haven't put a word about it anywhere in the docs.

verruckt24 438 Posting Shark

My first job after completing my post grad was in a very small organisation - I was the eighth guy. So in almost no time I was conducting interviews for potential candidates and was doing so for a long time after that. From my experiences of those days -, I could say that if not 199/200 it was pretty much 150-160/200. We used to hire in a lot of interns and it was one terrible situation.

Also I like the process in niek_e's country very much, you can certainly not fathom every quality of a candidate in a 30 minute process. Especially when he is nervous because of the same reason that he pretty much needs to showcase every weapon in his artillery in that short span of time. But again this isn't a feasible solution in the country that I (and s.o.s) live in.

One of my techniques was to ask the candidate to suggest a few topics that he was strong in, where he feels more confident and then asking questions to check how good he actually is in those areas.

verruckt24 438 Posting Shark

No. it isn't.

verruckt24 438 Posting Shark

The document for the SMPP Protocol v3.4 can be found at SMS Forum.

The open source library for SMPP along with the API Docs can be found at Open SMPP / Logica

verruckt24 438 Posting Shark

Thats because you are not deleting the element, but just skipping over it during the print operation. You will actually need to shift the elements up by one position from after the element to be deleted for the element to actually get deleted from the array. as described by me in my first post.

verruckt24 438 Posting Shark

What do you exactly mean by saving ? Please elaborate.

verruckt24 438 Posting Shark

To delete an element of an array shift all elements up by one index position starting from the next element from the one to be deleted so that the element to be deleted is overwritten.

For e.g. If you have an array: 4 9 13 10 17 3 20 and you want to delete the element 13, then starting from element after 13 (10) shift all elements one position to the left so that 13 is overwritten by 10, 10 by 17, 17 by 3 & 3 by 20. Having done this you would have deleted the element 13.

You could avoid this process using some of the methods from the Arrays Class, but this is just how to do it at a low-level.

verruckt24 438 Posting Shark

Yes, the information on this URL describes the BST in detail. To add further lets explain what the BST is actually. The BST or a Tree in general in the context of Data Structures, is a collection of Nodes. Where a Node has the following properties:
- Each Node has a data element (sometimes also called as the key)
- Each Node has a left Node which can also be called as a left child or the left sub tree.
- Each Node has a right Node aka right child or the right sub tree.

From this information, following the OO design principles you can create a Node class as follows:

class Node{
int data;
Node leftNode; // left sub tree is itself a Node very much like this.
Node rightNode; // right sub tree is also a Node very much like this.
}

Addition in a BST is the process of finding the right place for an element/key. According to the definition of a BST - all keys in the left sub tree of a node should be smaller than that at the current node and all keys in the right sub tree should be larger than (or equal) to the key in the current node. When you are about to add an element in the tree, you make comparisons that help you decide the correct position of the key in the tree. This process should be carried out something like this:

verruckt24 438 Posting Shark

Try it and see for yourself, if it doesn't work tell us the error.

verruckt24 438 Posting Shark

Just marked the thread solved if your query has been resolved.

verruckt24 438 Posting Shark

yes... it will be good for you to start in HTML or CSS.. Try to use www.w3school.com..God Bless You for your study

Ehh ? HTML is a markup language it is used to generate static web pages to be viewed using a browser. He was asking about programming languages and Java in particular.

verruckt24 438 Posting Shark

To repeat what BJSJC has said, there is a sticky at the very top of the forum which lists out all things that a beginner of the language might require including free online books, tutorials, links to get the JDK, names of a few of the best books etc which would require sometime to be digested. So for all your needs for a few months from now you could keep dropping there.

As for the books my personal favourite is "Thinking in Java" the site also includes links to download the book's pdf version along with it's source. The current edition is the 4th but the 3rd is equally nice with a few changes in the 4th.

As for the roseindia site do not refer to it. They do not follow the right practices.

verruckt24 438 Posting Shark

Actually someone called Peter Budo was source of me trying IntelliJ Idea

Yes he pitches a lot for IntelliJ ;) One of my co-workers who actually used to sit beside me (stephen84s) told me once that budo is a great fan of the IDE and recommends it more than often.

As I said I have never used IntelliJ so I cannot comment on it, part of the reason for it not being used would owe itself to the fact that it wasn't free (until recently, atleast thats what I guess) now that it is and so many people gunning for it I have made up my mind to try it.

verruckt24 438 Posting Shark

I have never used IntelliJ. My personal fav is Eclipse by far. JCreator is another good IDE for small projects but when things start getting serious where you require all the services offered by a host of varied plugins nothing comes close to Eclipse.
I have used NetBeans and the slowness that it brings to the machine really s**ks big time. It actually should be only allowed to run on super computers as it slows down machines with even 3 Gigs of Ram.

verruckt24 438 Posting Shark

the application below is what i did so far, please give me feedback

If it does what you have been asked for, if it works for you. We cannot be more happy. :)

verruckt24 438 Posting Shark

You could use this tutorial for it. But if you haven't been taught while loops then maybe you are not supposed to use them till yet.

verruckt24 438 Posting Shark

You mean once it is done your program should ask him for another class and so on. What you need to do is to use a menu and keep returning to it. So the menu should be printed in a while loop which has a termination clause that the user would enter when he no longer wants to go on. Say for example your main menu would look something like this:
1. Enter a Class to be described
2. Exit

Here you execute the while loop (or a do-while one if you think the user would want atleast one class description everytime) till the user enters the option 2, for which you just terminate the program.

While you are at it, I suggest rather then using your current way of allowing the user to enter the name of the class wherein the user has a chance to make a typo, you use another menu inside the main one. which lists out all the classes for description.

Something like:
1. Rogue
2. Hunter
3. Warrior and so on...

So that instead of entering the class name the user just has to enter the number associated with it. This menu would be printed once the user selects option 1 from the first (main) menu.

verruckt24 438 Posting Shark

Where are you using the counter to check whether it has been incremented or not. Post the entire code.

PS: He beat me to it.