verruckt24 438 Posting Shark

String objects are immutable and you can always reuse something that is immutable because you know that it isn't going to get modified. When you are writing "String s = new String("hello");", you are creating an unnecessary object; not only that it is also inefficient cause objects creation itself is. Moreover an object created this way cannot be reused. If this statement gets called in a loop or in a method it would unnecessarily create several objects which could all have been represented by a single one. So always use the "String s = "hello";" version instead of the other, this way any other string object with the same string literal can reuse this one.

PS: You seem so intelligent when parotting intelligent people....Here the intelligent person is Joshua Bloch, psst...but let this be sold on my name.

EDIT : Beaten, Peter has pointed out the exact article/item I was mentioning from.

verruckt24 438 Posting Shark

strtokeize with '.' symbol...
so it will be
java is an object oriented language.
it has many feature including 1
.1 robust 1
.2 inheritance.
java is a interesting language.
when you get each string like this..
so you check if else condition to rearrange this statement...

Why not on ". " (period and space character) then ? It would avoid all the trouble for one thing.

plz mark solved previous post String array to object...it will encourage me...

Does seeing your "SolvedThreads" counter go up the only thing that encourages you ? So that you keep on repeating the same thing after almost every post. Whatever happened to the good feeling of having helped someone solve something.

@OP: To split sentences you would need to check for either of the two things. First ". " (period & space character) as mentioned above and then the period and the new line character for sentences starting on new lines or paragraph as these would not be necessarily be having the space character after the period character.

musthafa.aj commented: offending by making fun of my word "SolvedThreads" +0
GeniusLives commented: I agree. +0
verruckt24 438 Posting Shark

hai this thread is posted by me
i just signed into the site n i am shocked to see the arguments
n someone marking unclear to masijade!!!
i am new to this site n as far as i know he is highly talented n has good patience in clearing the doubts of people
and i think this site is for people to develop their programing skills and so i think its not so good to spend our time in this way instead of discussing and improving ourselves
thank you

All this, by the person who started this crap in the first place. When Salem wrote "Have you ever heard of a search engine ?" He meant to ask you in a very polite way that why wouldn't you consider searching something on the net first. Not only this, we have a lot of such threads started by you. Consider searching as the first option before you post anything, read the rules of the forum about posting and asking for help and while you are at it up vote the post masijade so kindly wrote for you.

verruckt24 438 Posting Shark

"Unnecessary crap no one asked you about and no one's impressed by."

I guess you forgot the title to your post.

Salem commented: LOL +19
Ezzaral commented: Sounds about right to me. +10
verruckt24 438 Posting Shark

The very first thread in the forum has answers to your question.

The next time please take a look around and get acquainted before you post such questions.

verruckt24 438 Posting Shark

A constructor is a method that is used to "construct" a new instance of an object. You put various initialization stuff in there such as values that some of your variables should be initialized with. When you are constructing an object you sometimes require that the object shouldn't be constructed with the default values for the instance variables but something other that, something of your choice. To give you an example assume the construction of a Daniweb member, when the member object is constructed it is already alloted with 10 reputation points and not the default 0. So you would implement this as:

class DaniwebMember{
private int reputation;
private int posts;
private string username;
// other stuff 

//parameterized constructor 
public DaniwebMember(){
    reputation = 10;
    posts = 0; // need not do this, since the default is 0 anyway.
    // other init stuff
}

// other methods
}

Constructors can be parametrized or without any parameters. Those that accept parameters are known as parameterized constructors. There could also be multiple constructors for a single class indicating that the object could be initialized in multiple ways. This you can find out if you surf the Java APIs for some classes. If you do not provide a constructor for your class, Java will provide one for you which is known as the default constructor which will obviously not accept any parameters. But if you do provide a parameterized one it won't provide a default non-parameterized one for you. This is because it …

scratchwiz commented: thanks... =) +0
verruckt24 438 Posting Shark

Is this really a true story?

No, it isn't. It is more of an urban legend. Check the link given by jonsca.

verruckt24 438 Posting Shark

>alcay : I want to be programmer
Well C is a good place to start learning. Even C++ is fine. But C++ is considered an extension of the C language and for many reasons it indeed is. So normally tutors, schools, colleges etc do start with C and then move onto C++.
The reason I would prefer C is C++ being an OO language you would be expected to fathom the OO fundamentals along with the basics of programming, now sometimes this may work, learning the OO concepts parallel to programming so that you are brought up into OO paradigm but for someone it might also be a large chunk to chew what with language syntax, constructs, various in-built data types, environment of the language, editors and some programming conventions like naming, indentations etc. there's already so many things to learn while you are starting.
So you start with C and once the seeds of programming & logic-development have been well planted in your mind you could move onto the concepts of OO among others.

Also you would have to start on you own, yes there will be a lot of help in the way but you need to take the first step. There are "Get Me Started" sticky threads on top of every forum so whatever you decide to start with you have the way paved already.

Nick Evan commented: Finally someone with a descent post in this thread. +12
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

>AbhikGhosh

What do you think you are doing by giving away code like this ? It is for him to do and for us to help him do it on his own, thats the whole essence. I suggest you try to avoid this in the future.

verruckt24 438 Posting Shark

Hmmm, I guess you missed the "We-offer-help-only-to-those-who-show effort" theme of this site. Please take a careful look around and while you are it drop the IM/chat speak we give more respect to full words. ;)

Salem commented: Yes! +19
verruckt24 438 Posting Shark

From what I have understood you need to do, it is something like this:
You have created/worked on the project on a different computer on eclipse and now you want to switch the machine for some reason. If this is what you need to do, follow the below mentioned:
1. From the main menu bar, select File > Import.... The Import wizard opens.
2. Select General > Existing Project into Workspace and click Next.
3. Choose either Select root directory or Select archive file and click the associated Browse to locate the directory or file containing the projects.
4. Under Projects select the project or projects which you would like to import.
5. Click Finish to start the import.

This is straight from the Eclipse Help Contents, for further details select Help Contents from Help menu and type "importing existing projects".

Tell me if this helps.

verruckt24 438 Posting Shark

I have seen several posters asking for help on programs converting an Infix expression to a Postfix one. I have written a program to convert a simple Infix expression to a Postfix one so that people here can be directed towards some sample code from which they get the idea to writing one. I have also provided comments describing what the code part is supposed to do in that block, the idea here is to discourage blind copying and to encourage the understanding of the program. Once the idea behind such a program is undestood, even a beginner can write one for himself.
There can be many ways in which a particular solution can be implemented, this impementation is based on this text.
Lastly I want to mention why I call this program one that converts a simple Infix expression. Thats because I haven't written it to take into consideration complex expressions with paranthesis in them, also I haven't written it for an exhaustive list of operators (the operators I have taken into account are mentioned in the source code). Programmers can take an hint from this simple program and add their own additions to it.

verruckt24 438 Posting Shark

Firstly I guess you need not dump all generated permutations into an array. You should only dump those permutations which generate a word out of the unscrambling of the original word, which you can figure out by comparing each genarated word with the list of all dictionary words that you have gathered.

Searching each generated word with a long list of existing words (which might be in thousands) is itself a time consuming task, but you can have the dictionary words put into an ArrayList and then compare each generated word using the contains() method of that class, so I guess this could be much faster than iterating over the words.

Here in this algorithm another very important decision is to generate as few unscrambled words as possible. So in this sense you should try to able to discard a combination of the letters, which is not going to form a word, as early as possible. For eg. in the example you've given of 'time', you should be able to detect that there are no words of length four starting with 'tm' and hence shouldn't move further into generating the permutations starting with this combination. The more longer the word the earlier the better. So if suppose you have been given a scrambled combination of the letters of the word 'difficult' and you come to know that there are no nine lettered words starting with the two lettered combination 'df', you can eliminate the generation of …

VernonDozier commented: Some good ideas here. +15
verruckt24 438 Posting Shark

How about an expansion of your username itself - Green Extreme, it would do more than just cause a stir especially in these days of Global Warming concerns.

What say ?

Grn Xtrm commented: Great suggestion. Thanks. +1
csurfer commented: Good one there lol... +3
ahihihi... commented: :) +1
verruckt24 438 Posting Shark

I should say I have to agree with Serkan Sendur here in this thread. I'm not saying that I have the same feelings for Narue as he does, but I mean I agree with him when he says "You have the liberty NOT to read this thread"

I don't know why Nav33n and MosaicFuneral, (and don't take this the wrong way guys) have to act like some personal bodyguards for Narue. Don't think at all that I endorse the way Serkan talks about Narue or anything else, but c'mon guys don't crowd up on someone, Narue is quite capable of handling such things, let her and Serkan sort it out. I say this because I have seen a couple of threads by Serkan where he says something and then all the other members just mob up on him trying to tear his every post apart. If he does or say something wrong the moderators would take appropriate action against him but let us not be judgemental about anything and everything that he has to say.

MosaicFuneral commented: He's just so easy to play with. +3
verruckt24 438 Posting Shark

Oh? They posted a question. They want an answer. How are they supposed to know they should not expect an answer to their question?

Because they are posting a question pretending it to be an "answer" to the initial question, in the first place. Secondly as I have mentioned they are already informed through the notice that the threads' old enough and they should "perhaps" start a new thread. If they still persist with their instinct that they might get an answer let their instincts be proven wrong.

Let's stop supposing, shall we? Deal with reality, please...

I am saying here that if they are not smart enough even to read the dates and read some published announcements, their questions won't get answered thats all.

And the background of the coding forums say Use Code Tags. 80% of new posters don't. Why would one think an 'announcement' would help this situation?

Yes, and there's also an announcement about showing effort on your homework, no one follows it either, but the forum regulars make them follow it with their in-your-face and straight forward replies that they offer for anyone not showing effort. In the same way by not answering their questions (we would not be knowing they have posted anyways since the thread wouldn't be bumped) we would be giving them the right signal that the announcement on the top is not just to take up unwanted space but actually to be followed. now can't we do that ?

Comatose commented: Yup. FTW! +12
verruckt24 438 Posting Shark

No, We are not hiring now anyways. ;)

stephen84s commented: lolzzz +7
verruckt24 438 Posting Shark

I need it I am also doing same project in java as my final year Project.

I don't know what this line suggests to you, but for a majority of the people here it suggests that YOU are the one looking for it.

VernonDozier commented: It certainly suggests that to me. +11
verruckt24 438 Posting Shark

I am sure you mustn't have been aware of google then because these were one of the top few results there.
1. Threads in Linux --- 1, 2
2. Threads in Windows --- 1

Salem commented: Tsk tsk, he wanted "4" help and you only gave him 3 links ;) +36
verruckt24 438 Posting Shark

I may not be able to answer this question eventually but could guide the first few steps. Well, you don't need to convert the array strings to 1s and 0s and then the 1s and 0s to analog signals that flow in wires all you have to do is throw the data from the client machine by opening a connection with the server on whatever socket the server listens and then on the server side receive the dataand it will be as it was sent bu you. On the server side you could listen to incoming conenctions from various clients by using the accept() method of the ServerSocket class.

You could also "flatten" the array to a file and then send this file over to the server where it inflates it to proper type (assumes type is known). Here the flattening is called serialization and the inflation of the object from the file is called deserialization.

You could always google the terms with "java" to find more about them.

Edit : Damn !!! stephen84s kept it short just to beat me to it. ;)

jasimp commented: He may have kept it short but he had more links ;) +9
verruckt24 438 Posting Shark

There are three methods in MouseEvent which could be of particular help, getX(), getY() and getPoint(), getPoint returns the X,Y position relative to the source component while getX() returns the X coordinate and getY() returns the Y coordinate.

Now what you could do is, divide the image in sections for bets and then on the mouse click get the coordinates from which you could decide what section of the image has been clicked on and hence what part of it has the bet been placed on.

darkagn commented: Good idea to section off the image, thanks :) +3
verruckt24 438 Posting Shark

what is this (File f=new File(file)

Well, thats what happens when you put yourself into a habit of "finding out code" instead of writing it yourself - you are stumped by the most basic and rudimentary things. As something I am personally against, I won't help you understanding this code as it isn't written by you.

However I can help you, write it on your own.

You need a Swing component, something like a JFrame of JPanel, put a JLabel onto it (big enough), onto which you can show your images. To auto run the slide show you change the image on the JLabel after periodic intervals using the Thread.sleep() method. (If you know what it is!)

If you want to develop a more complex slide show, where a user can hit the "prev"/"next" button, you can have this functionality built-in in your application by arranging the images to be shown in a particular order and then running through them back or forth as suggested by the user. You can then start the sleep interval on every hit of the prev/next button anew so that each image is displayed for only a specified time duration. To provide more features such as stopping the auto changing of an image, you can make the Thread stop so that it doen't flip images on it's own. To allow the user to set a custom or pre-specified interval for changing the current image you can make use of checkboxes (for pre-specified …

BestJewSinceJC commented: good advice +4
verruckt24 438 Posting Shark

Who's stopping you then ? Put out two labels mentioning "Enter string 1" "Enter string 2", put out two textboxes allowing the user to input the same. Use a label to finally show the result of the comparison. What was so difficult in this. Take a look at the Swing/AWT tutorials if you are finding yourself uncomfortable with GUI development.

And start using code tags, you have already 12 posts.

Ezzaral commented: "What's stopping you?" was my thought exactly as well :) +18
verruckt24 438 Posting Shark
textField2.setText(Integer.toString(woorden));

This statement isn't correct. You should rather do

textField2.setText(String.valueOf(woorden));

And as far as the error goes I get none such. Try this code identical to the one written by you. This runs perfectly well at my place. Also the compiler isn't correctly pointing out the error since I had sited you the docs for the split method from the String class itself. (Apart from the fact that I have used this method a thousand odd times)

String str = "disaster posts in the Java Forum";
String splitPattern = " ";
String [] tokens = str.split(splitPattern);
		
for(int i =0;i<tokens.length;i++){
	System.out.println(tokens[i]);
}
BestJewSinceJC commented: Carefully explained +2
verruckt24 438 Posting Shark

1). Cast null with Component
2). Convert sum variable to string type

Both of these aren't required at all.
1. NULL does not need to be casted to anything.
2. If the int is within a string, it's acceptable.

Ezzaral commented: Glad that you corrected that nonsense. +18
verruckt24 438 Posting Shark

Who cares.

I do. And may be several others, who for reasons known to them did not speak out.

stephen84s commented: me too +7
verruckt24 438 Posting Shark

The code you have posted earlier does not contain this anywhere

System.out.println("Element at index 1: " + scores[1]);

So post the new code again. Also I am obeserving that even after so many posts you aren't taking much from them. Read the posts carefully, it isn't much difficult a task and you have been already given enough pointers but you don't seem to learning much from them. It would help to learn one thing that we aren't going to spoon feed anyone here, giving him the code in parts one by one explaining everything to him one at a time, we need to see some effort better than this from you.

@BestJewSinceJC : Yes you have a point there, that when you declare a variable false a while condition checking that variable will never enter the loop, but the problem he mentions - "cannot-find-symbol" will not be caused by that anyway. Why it does cause can only be told when he posts his new code.

olgratefuldead commented: Very helpful +1
verruckt24 438 Posting Shark

So then when the line runs longer than the maximum width allowed for the post screen, how do you plan to show that ?

If you use horizontal scroll bars for it, then lines can become too too long. This again causes problem to read, as one has to keep scrolling back and forth. Also after reading a long line, it's confusing to figure out the line exactly below the current line.

For better reading abilities it's always good to keep the line upto say 80 characters. It's like in the newspapers even though they have lot's of width they prefer to break a long article into multiple vertical columns than to allow the lines to stretch to length. ;)

nav33n commented: Exactly! +10
verruckt24 438 Posting Shark

What are the criteria that one could be selected for the title. (MotM) Is it that it is only the number of posts that count ? Posting in the Java community I have come across several members that might not have those many posts, but have been a real help for others, the sheer number of their Solved Threads and Reputation tells the story. One such member has already been named, Ezzaral, He has been a revelation with all his posts, masijade, stephen84s and javaAddict are other such members.
And I haven't been in the C++ forum that much but around there, niek_e seems to be one such.

stephen84s commented: I second niek_e, hes the one who gave me my first good rep :P +6
verruckt24 438 Posting Shark
for(int x=1;x<=(num);x++)

Since 1 is not a prime number don't begin your loop with it, rather initialize x to 2.

Definition of prime : An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself.

verruckt24 438 Posting Shark

This depends on your relational design. As you mention information about your project, the hosts are "service providers" and the users are "service consumers/takers". You need to decide whether what relationship the hosts and users share. If a user can have content hosted on multiple hosts then there is clearly a many-to-many relationship between them, as hosts certainly can have multiple users.
Once you have decided this, you need take into consideration what attributes/information you would like to store for the hosts and the users. Each of these attributes would be fields/column in the tables. From what I understand, I don't think that hosts and users would share more than a few attributes and hence it is advisable to use two different tables for them.

>I would also like to allow the host admin to be able to add/edit/delete users associated to that host.

This is concept that you would have to implement in your coding.

verruckt24 438 Posting Shark

Hmmm... now you are saying something.

Nick Evan commented: *nods* +14
maydhyam commented: Yup! +0
verruckt24 438 Posting Shark

Federer is a better player than Rafa.

Sky Diploma commented: Lol I agree +3
verruckt24 438 Posting Shark

Which methods ? Have you even cared to go through the iText library and the Apache POI ? They both are stable production quality libraries.
Do your homework before posting blindly.

stephen84s commented: Exactly the tone to use for such posts +6
verruckt24 438 Posting Shark

.For this simple questions

Thats exactly where my previous post targets, if you think this question is so simple, why in the first place do you need others help.

PS : I confess, I only got to know the new keyword in java through your post. Actually to tell you the real thing just because of that I never created any object in the Java language all this while. but I hate you for spoiling my cover-up and also really hope that someone posts the correct answer to this question, cause, psst...be silent, I am going to need some objecst in my upcoming project. ;) I really hope my boss isn't on daniweb. :(

javaAddict commented: Excuse me, what is an Object? :) +5
verruckt24 438 Posting Shark

Every mod's opinion is respected and taken in good spirit as we know that you are the ones who need to do the policing around here. Thats the reason I gave so much an essay of explanation to peter ;).
What my point is that we (Stultuske & I) aren't the criminals you are lookign for but just some freak crazy college guys trying to squeeze in some fun here.

stultuske commented: not a college guy any more, but "hear yeh, hear yeh" ;) +5
verruckt24 438 Posting Shark

You should go bald I guess.

Double hoursWorked = input.nextDouble();
      // read value for hours worked
      if(hoursWorkedInWeek <=0.0){
          System.out.println("Hours worked cannot be negative/zero.");

This is the height of being careless, really Coyboss, this is what exactly stephen84s was trying to tell you yesterday and I mentioned the same. Just check what variable you are reading and what variable you are comparing. And you don't stop at once you go on and do it twice.
Here it is

Double payRate = input.nextDouble();
      System.out.println();{
      if (hourlyWageInDollars <=0.0){
          System.out.println("Hourly wage cannot be negative/ zero.");
      }

You have not even taken care to change the variable names have given to you, thats how careless you have been and when somebody points that to you, you try to get back at him.

stephen84s commented: Finally someone noticed what I saw in him at the start :P +5
verruckt24 438 Posting Shark

Firstly, you haven't called the method spalsh() , though this won't in any way affect the working of your code, but just mentioning the fact. So you should include a statement such as this as your first statement in the main method.

splash();

Secondly, you say the program stops after requesting the three inputs from the user, but haven't you written it that way? You haven't made a call to the calcFV method after asking for the input. So do that.


Also since you are printing out the futureValue in the calcFV method itself, you can opt out returning it with the return statement but if you absolutely want to, you will also have to accept it in the statement that calls the method.

So after making the changes I have suggested you. your program should have a form like this.

import java.util.Scanner;

public class HW02_jsn{
    public static void main(String [] args){
        splash(); // show information about the program's task.
        // the three input requesting statements, with the user input scanning stmts in between them.
        double futureValue = calcFV(p,r,t); // this futureValue is different than the one declared inside the method calcFV
        System.out.println("Value is " + futureValue);
        // splash code here
        // calcFV code here
    } // end of main
}// end of class
zaraeleus commented: You have been very helpful and patient with me. I appreciate that very much! +1
verruckt24 438 Posting Shark

Give me the complete code for this.

Yeah and you give us a billiion dollars for that.
Only the forum rules are stopping me from telling what reply you should be getting for that.

Have you taken care to read the forum rules before making any such nonsense requests ? If not, do that.

When you have done that then you might come back to us asking for specific help.

stephen84s commented: lolzzz +5
verruckt24 438 Posting Shark

When you say you have working knowledge of Java I assume you have written enough programs in the langauge. Since you say you are not able to make the next step, picture it this way, a project is nothing but an extension of programs, it is essentially a collection of programs that you may have written at the basic level. Say for example if you have written programs for queues, stacks, linked lists etc a project of say implementing a print spooler might need you to use the queue with that it might also need you to perform some I/O which you might have learnt in simple programs like Console priting/reading and File reading/writing it might also need of you to do some tasks simultaneously as there might me many users of the printer wherein you would require the knowlegde gathered with programs of threads etc in this way a whole lot of basic programs interacting with each other collectively form a project.

Now for the project idea part, you could yourself devise a project of your own in which you might want to make use of all or some of the programs written by you till date. If you aren't able to figure it out yourself still, I suggest you search this forum for similar threads since this question has really been asked a lot and you would certainly get an idea for your project out of it.

verruckt24 438 Posting Shark

masijade looks to be in top nick !!!

masijade commented: Thanks. Just a wild hair I guess. +11
verruckt24 438 Posting Shark

1. Use code tags to post code.
2. Instead of asking of us whether your code is ok or not you can check it yourself, if it does what it is intended to do you know what it is, whether it doesn't you still know what it is. Why do you need our approval.

@~s.o.s~ said : If the given character is not a parenthesis or bracket, move over to the next one

3. doesn't this pretty much explain what you got o do when there are no paranthesis at all ? You just keep on moving over all the characters till the end of the expression.

Salem commented: Well said +26
verruckt24 438 Posting Shark

Also to get you started on it...when working with a OO langauge always break down the problem domain into classes and methods.
You have most of it done since you have been given classes too. Now you can identify the individual methods that should be put into each class and write your code.

jasimp commented: Very helpful +9
verruckt24 438 Posting Shark

What the hell are you guys doing here ? This isn't somekind of advertising board for corporates. This forum's main aim is to make people learn while they are being helped. You want to show that you are helping people while making them dependent - not to talk about making greedy porfits for your own organisation.
What you are doing is outright cheating, you are showing people way to cheat their professors/tutors when actually this place's culture promises to be the exact opposite.
Don't make porfits for yourself at the expense of others. I doubt the experts you so boast off are really 'experts' at all otherwise you would be wanting to make larger, complex commercial projects instead of exercising their epertise in school/college - in short kiddie - projects. I hope you get it !!!

stephen84s commented: Couldn't have put it better +3
Salem commented: Good post +23