javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

But why would you want to add them. I assume that they are coordinates. What is the meaning of adding coordinates?
Sure they are numbers and arrays and you can add them, but I don't seem to know any mathematical theorem that it requires the addition of the X,Y,Z coordinates.
What are you trying to accomplish?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

See I told you, they have nothing good to offer apart from satisfying their egos.
Sadly, in this forum, we are not provided with a means of opting-out of future communication. All the 812,117 members are already locked to the mercy of a few mean guys.

You still haven't answered my question in my only post here:
>
Now explain what good does Megha's code have or what did his post contributed?
<

And please answer with arguments, not just flaming what you don't like. You accuse us of being judgmental but all of our posts contained arguments backing up our position. (eg. By providing ready code to new programmers will not help them learn.)

Now I also expect a solid answer to my above question with solid arguments.


EDIT: jon.kiparsky can you explain the joke you made: "Waiter! Four orders of fugu please!"

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do you even bother to read the error messages that you get? They state the error and the line that it occurred.
"DCS2.java:29: variable ad might not have been initialized"
What you don't understand from that. Is it so difficult to go and initialize the variable ad ?

Also there are some other errors that you have been told how to fix them:

else if (..) {

} else
   break;

That may compile but is wrong. You need the break to execute when the if statements finish. With what you write, the break will execute only inside the last "else". If you enter any of the other ifs, the break will not execute. The last "else" is not necessary since you haven't put any commands inside.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

May I ask a question? Probably it is stupid but just in case to make sure.

Have you compiled the HelloWorld.java file and where the HelloWorld.class file is?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What is a 'picture puzzle' ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Yes but this: 2323237777777 is an int. And int numbers can not handle that; it is too big.
This is a long: 2323237777777L

long me = 2323237777777L;
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you even bothered to read it? It says: "Column not found".
Now what do think could be the problem? Also the error message tells you exactly the line where that error occurred.

It is not that difficult to understand that you are trying to read a column that doesn't exist.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You already have one 2D array: coordinates1.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want to add a picture at the GUI, you need to look at the API of the JLabel class.
It has a constructor that takes as argument an Icon. Or you can the method: setIcon. From the API the argument (Icon) is an interface, so you need to look at the class ImageIcon that implements the Icon interface.

So create an ImageIcon instance with your image and put it to a JLabel. Then display that JLabel.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also don't start a new thread with the same question and unformatted code. You think we have the time to keep track and answer 2 identical thread? If you have something to add do it here.

And if the compiler says that variable wage might not have been initialized then just initialize it with a value when you declare it.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Your code tags should end.

Also you need to be more descriptive. What your program is suppose to do? What kind of errors do you get and what output

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi... please help me to solve this....
I need to get the following output:

1
2 2
3 3 3
4 4 4 4

and so on...

Start a new thread. And use 2 for loops one inside the other.
The 1st iteration of the loop will print 1 only 1 time.
The 2nd iteration of the loop will print 2 only 2 times.
The 3rd iteration of the loop will print 3 only 3 times.

The 1,2,3 are the index of one of the loops

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The code has already been provided posts ago.
It has been also established that we shouldn't give ready code, rather than help the poster find the solution.

Now why do you think mnmw, that Megha's post had any meaning?

He posted code that had already been posted and gave solution with no further explanation and without teaching anything. And that happened 1 month later.

Not to mention that the code is not correct. That is not the right way to write code. If someone follows that example they will learn nothing.

Now explain what good does Megha's code have or what did his post contributed?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Check out the indexOf method of the String class:

String s1 = "www.google.com/search/"
String s2 = "google"

int index = s1.indexOf(s2);
System.out.println(index); // 4

If "index" is -1 then the s2 is not inside the s1. Else it returns the position of the s2 inside the s1, which is 4. "google" starts at the 4th character in the s1 String (starting from 0)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

it returns something like

com.login.entry.dao.UserInfo@7f906b

n times

That is not null. And read my previous comments:

If you are going to call the toString method better override it in your UserInfo class because what you call is the inherited method of the Object class.

What you get is what the toString method of the Object class returns, because you haven't overridden it in your class.
And you shouldn't be using that in the first place. Use the get methods to display whatever you want.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

In the catch block, you set the LoginEntryException to be null and then you one of its methods. That will give you a NullPointerException. What is the point of setting something to be null and then use it. You need to initialize it. Just do e.printStackTrace and see what is going on. There are exceptions that you don't print

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You need to post what errors do you get. Don't expect that is easy for us to take your code and run it. Or that we read it line by line and expect to understand what you were thinking.

Also I happened to run the latest code and this is wrong: int i = 0; i < aString; i++ aString is a String. What is it doing there? You are suppose to put a boolean expression there in order to tell when the loop will stop.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You are calling the next method twice, without checking if it has a next element:

out.print("coming..................:"+itr.next());
out.println(itr.next().toString());

The first next call will return since you did that check at the while, but the second will not because you take the next element and you don't know of it has one.
If you are going to call the toString method better override it in your UserInfo class because what you call is the inherited method of the Object class.
Also you need to pass allUsers instance at the request to a jsp page. Then iterate, take each object and use the get methods. What is the point of having get method if you are not going to use them.
Check the method: request.setAttribute("users", allUsers)
At the jsp do:

List<UserInfo> users = request.getAttribute("users");

Check the RequestDispatcher class to send the above request to a jsp.

After you got the users instance use a loop to get each element and then use the get methods to create a table. Check the <table> tag.

And don't use this:

out.print("..");
out.println("...");

Don't use servlets to display data at the browser.

Check the tutorials at the top of the JSP forum

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Your code is unformatted and you failed to indicate where the error is. Reade the error messages that you get. Don't expect others to do it for you:

Exception in thread "main" java.lang.NullPointerException
at Bank.main(Bank.java:25)

At the file Bank.java line 25 you got a NullPointerException. You are trying to use at that line something which is null. Make sure that at the line all the objects are initialized and have value.

What line is it at your code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There isn't a parseInt method, unless you define one. The Integer class has a parseInt method but in order to call it you need: Integer.parseInt("50") not Integer.parseInt("fifty")

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Then write various if statements.
If the user enters twenty one, then separate that input and you have "twenty" and "one". So you don't have to write if statements for every number.
Have a method that returns the number.
For input "twenty" you get 20
For input "one" you get 1
Then add them.
You need if only for the numbers:
1,2,3,....20.
30,40,50,...100
The rest are a combination of the above words:
one hundred and twenty seven

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There is no such method, you need to create your own:

String strNum = "fifty";
int num = 0;
if (num.equalsIgnoreCase(fifty)) {
  num = 50;
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at TheatreRevenue$CalcButtonListener.actionPerformed(TheatreRevenue.java:99)

At that line and file: TheatreRevenue.java:99 you are using something which is null. Go to tha line and see what is null and make sure it is initialized.

Also the code tags you are using should end with

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What class is this: d.ymd ? Did you write it. How do you expect to call d.dmy if such method doesn't exist.

Look at the API of java.text.SimpleDateFormat, for formatting Date objects to Strings

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I can't understand anything from that code. Did you wrote that or it was generated by NetBeans?

Anyway. Assume that you have your form:

class MyForm extends JFrame {
  
  // declare components (text fields, buttons and others) 

  public MyForm() {
    // initialize the components put and add them to the form.
    // Here is when you need to use the NetBeans gui builder. When placing the components at the form.
  }
}

After you are done, whenever you want to display that form simply call it:

MyForm form = new MyForm();
form.setVisible(true);

Remember it is an object. It can have attributes with get/set methods. You can pass as parameter another form and hide/show it depending on a button clicked. Or you can have the MyForm you created as a local attribute to another form. By calling setVisible(false), you can hide it and keep on calling any methods you have declared for that object as long as it is scope.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Better use the log4j.properties option better. Or if you look at the API you can programaticaly configure the log4j.

Also check this out:
http://www.vipan.com/htdocs/log4jhelp.html

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When you start the application, the main method is executed. You have a class as the "starting point" and inside there is main method. Inside the main method there is probably an initialization of the object. Post what is inside the main class.

And then do the same thing. If you want to show that new frame you created, just initialize it by calling 'new' and then since it extends the JFrame just call the setVisible(true) method.

And don't use IDE for Gui and swing if you don't know what you are doing. Read some tutorials on how to write swing applications by hand and forget any GUI builder there is.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What code do you have in your main method in order to start the application?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can create a separate java file. That class would be the form. It will have fields and labels and buttons.
When you select the option, instantiate that class. It should extend the JFrame class. So when you create that instance and make it visible enter whatever you want. You can have buttons with actions as well.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want something converted to int or double do what you correctly did

interest = (int)(.....);

Of course you were trying to convert rate to a double too. I haven't looked what is its type but if it is not double and you want it to be double do what you did with int:

interest = (int) (balance * (double)rate);

Or

interest = (int) (balance * 1.0* rate);

If balance is already double then you don't need the casting. If balance is double then when you do this:
balance * rate, then you multiply double with something else which will result double:

interest = (int) (balance * rate);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

It is not good to add the throws exception at the main method. Exception are meant to be caught and handled, not thrown at the main. Also the close needs to be in a finally. But if you try this:

try {
     BufferedWriter bw = new BufferedWriter(new FileWriter("write.txt"));
} catch (IOException ioe) {
     System.out.println(ioe.getMessage());
} finally {
    bw.close();
}

It will not compile because the BufferedWriter is declared in the try and it is not visible in the finally. So declare it outside the try, so it will be visible in the finally, and initialize it in the try.

You will also need an extra try, catch because bw.close() also throws an exception, so:

} finally {
    try {bw.close();} catch (Exception e) {/*you don't need anything here*/}
}
import java.io.*;
      class Writefile{

      public static void main(String []args) {
            // Declared here
            BufferedReader br = null;
            String name = null;
            BufferedWriter bw = null;
try {
      // Initialized here
      br = new BufferedReader(new InputStreamReader(System.in));
      bw = new BufferedWriter(new FileWriter("write.txt"));

      System.out.println("Write into the file write.txt. To finish typing input \"end\".");

      while(true){ //loop continues unless typing in the "end" line
        name = br.readLine(); // read each line of strings you typed in

        if (name.equals("end")) // check the content of input. If it is "end"
            break; // then jump out of the while loop
    
        bw.write(name);
        bw.newLine(); // for changing line when writing to a file.
      }

      bw.close();
} catch (IOException ioe) {
  System.out.println("Error: "+ioe.getMessage());
} finally {
    // finally start …
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I haven't tried it, but can you try this:

b obj = new a();

((a)obj).a1();

With this: (a)obj you are casting the obj to the a class. Then calling the a1 method.
You can try it, but I don't know if it will work.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
/**
 * Class Card which holds the card's suit and value as 2 char attributes.
 * Contains many methods for the use of the game.
 * 
 * @author (Lee Norman) 
 * @version (July 2010)
 */
public class Card
{
    private char suit;    // The suit of the card (C,D,H,S)
    private char value;    // The value of the card (A,2,3...10,J,Q,K)
    private String SuitName; // The suit's name(eg,"ace")
    /**
     * Constructor for objects of class Card
     * Creates a Card object with the parameter values as attribute values
     */
      Card(char suit, char value)
    {
         this.suit = suit;
         this.value = value;
         
         if (suit != 'C','D','H','S')
         {
             System.out.print("This is not a valid Suit");
            }
    }

I am getting an ')' expected error and I cannot see where this is needed.
This code is java in BlueJ and doesnt offer any more help on the error.
The error highlighted line #23.
Help/advice would be appreciated, cheers.

You need something like this:

if ( (suit!='C') && (suit!='D') && (suit!='H') && (suit!='S') )
         {
             System.out.print("This is not a valid Suit");
            }
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

please any one can how tell

how to insert byte array ( this array is consisting of bufferedimage data in bytes)

into blob field in mysql database ....:idea::idea:

please give any idea

thanks in advance.........

Use PreparedStatement instead of Statement. And check the API for BLOB class. It has link for a class the implements it and has the constructor that you want.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also you do this:

ma = ad/nmp;
}
else
 break;

which is wrong.
After the else you put commands. The break belongs to the switch, not the if-else statement. With the way you have it, the break will execute only after the else. If the first 'if' is true then the break will not execute because the way you have it, it belongs to the if. The else that you have there does nothing so it is not needed.

And what is so hard to understand from this:
"Found double. Requires int" followed by the line of the code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try to print this:

String s11="INSERT INTO "+table+" "+"  VALUES(mani,'"+image+"')";

Before executing it. What happens is that when the String s11 is constructed this is trying to take value: "+image; It "converts" the image java instance to a String. Meaning this is called:

String s11="INSERT INTO "+table+" "+"  VALUES(mani,'"+image.toString()+"')";

And in the end you have the String representation of the Image java class instance . Not the contents of the image saved to your disc. You were trying to save a String: '<image.toStirng()>' not the actual image

Also what mani is? Is it a variable or the username. Because when you try to execute it this will execute:

INSERT INTO table_sth VALUES(mani,'some text')

mani is not an sql variable, it will not execute.
This is what you want:

INSERT INTO table_sth VALUES('mani',...)

And if you want to use BLOB, use a PreparedStatement instead. Then check the BLOB api. Specifically the class SerialBlob that implements it. It has a constructor that takes as argument a byte array. Read the image's bytes and save them into an array and create the BLOB object. Then call the PreparedStatement.

I have never done this before but that is what I would have tried.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try to read what the hashCode method really does and what it is used for.
Check the API of the Object class, as well as the API of the HashMap.

Also don't use '==' to compare Strings. Use the equals method of the String class. And you also need to check, in the equals method that o and name are not null, before calling any method on them.
The d1, d2 will not be equal with the way you have defined the equals method.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

From the errors I assume that we are dealing with Applets so there shouldn't be any main method. If you want to use something anywhere then declare it, create it and initialize it.

Without some code to go with the errors it is difficult to suggest anything than speculations

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

import java.io.*;
public class date
{
public static void main()throws IOException
{
int d,m,y,days=0,leap=0,F;
InputSteamReader IR=new InputSteamReader(System.in);
BufferedReader br = new BufferedReader(IR);
System.out.print("Enter Day Number");
d=Integer.parseInt(br.readLine());
System.out.print("Enter the Month");
m=Integer.parseInt(br.readLine());
System.out.Print("Enter the year");
y=Integer.parseInt(br.readLine());
y=y-1990;

if((y%4==0)||((y%400==0)&&(y%100)==0))
{
leap=1;
F=m==1?0:2;
days=(y*365)+(y/4);
m=m-1;

if(m==1||m==3||m==5||m==7||m==8||m==10)
{
days=days+(((m/2)+1)*31)+(((m-1/2)*30)-F;
}
if(m==2||m==4||m==6||m==9||m==11)
{
days=days+((((m-1)/2)+1)*31)+((m/2)*30)-F;
}
days=m!=1?days+leap+d:days+d;
if(days%7==0)
{
System.out.println("Sunday belong to this date");
}
if(days%7==1)
{
System.out.println("Monday belong to this date");
}
if(days%7==2)
{
System.out.println("Tuesday belong to this date");
}
if(days%7==3)
{
System.out.println("Wednesday belong to this date");
}
if(days%7==4)
{
System.out.println("Thursday belong to this date");
}
if(days%7==5)
{
System.out.println("Friday belong to this date");
}
if(days%7==6)
{
System.out.println("Saturday belong to this date");
}
}
}


it says expected at line 26..help sooon!please!!

Then go at line 26 and do what the error says. It expects an ')'. In English it means that it misses an ')'.
Or do you expect us to count 26 lines. You didn't even bother to highlight where that line is at your unformatted code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

jon.kiparsky has already solved your errors. Read his suggestions and your error messages.
You have an else without an if.
It is:

if () 
  one command;
else
  one command;

For multiple commands use {}

When you don't put {} at the if, only the first line after the if is taken into account. The rest are considered outside the if. Then you put an else that doesn't have an if before it, because the if you had, has other commands between them that don't belong to the if so they are not connected.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 8, Tab count: 2
tlaa get vu.getResource: tabCount: 11
at javax.swing.JTabbedPane.checkIndex(JTabbedPane.java:1736)
at javax.swing.JTabbedPane.setSelectedIndex(JTabbedPane.java:572)
at view.menus.innerframe.admin.JMenuControlAdmin.controlJMenuItems(JMenuControlAdmin.java:53)

That says it all. Read the error messages that you get. Don't just throw them to other people.
At that line you are trying to set a too large index. It is like having an array of length 10 and are doing array[12]

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you need a multidimensional array then instead of an object, you can add arrays to the Vector.

Usually we read a file that has lines like this:
Name Age Phone
Jack 20 1122333

Into an object:

class Person {
String name;
int age;
long phone;
}

And since the file has many lines we use a Vector:

Vector v = new Vector();

while (read file) {
Person p = new Person();

v.add(p);
}

But in your case you can do this:

Vector<int []> v = new Vector<int []>();
      
int [] array1 = new int[5];  
array1[0] = ......
v.add(array1);

int [] array2 = new int[5];  
array2[0] = ......
v.add(array2);

int [] tt = v.get(0);

When you do this: Vector<int []> you explicitly say that that vector will only accept arrays of integers. You can omit it, but with that way the compiler would allow you to add any type of elements which is not very safe.

Vector v = new Vector();
v.add("aaaa");
v.add(1);
v.add(new SomeObject());

The above will compile. But then you would have to do casting in order to get the right type of element because at the above case the v.get(i) method returns an Object. With the first example the v.get(i) returns an int [] so no casting is required.

Also this <int []> part of code works only for java 1.5 and higher.

So you can add as many arrays you want.
And if you want …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Whole code for your pleasure to read it and use it here

I don't know why but that link doesn't work for me. I get an error saying that I can not access the page?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

This is a java forum not a jsp forum. Search for the jsp forum.

if you know show it please

Why? Why would we show you the code? What do we have to gain?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You don't use arrays, you use a Vector
Search for tutorials about Vector and/ or lists in general (ArrayList)

With Vectors you can add as many elements as you want it doesn't have a fixed size. Whenever you add more its size increases automatically, so you can add more.
You can add a single dimensional array as an element of a Vector or better , write a class that represents your input. When you read each line of the file create an instance, set its values and add it to the Vector.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

what error do you get ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Even if you do write code that create a file with the .jsp extension and save it at the server, what would be its use. You would still need to call it and display it to browser.
Even if you create a dynamic link based on the name of the .jsp file that you programaticaly created there is no practical use for such technique.

What are you trying to accomplish?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

dude actually i m not intrested in software develoment field....m focusing on n/w oriented career..

I m in final yr engg nw.....project work is compeltion part!!!

evry1 has diff choices....

nys will focus on ur rply 2...

thanx....

First of all If you have read the forum rules you would know we don't give homework and it also against the rules the way you talk:

i knw dis man...also ashamed 4 d same..
i nvr took ny of languages seriously.....
i hav 2 mail till 2mrw...
nys thanx 4 all ur concerns...

Use proper english! One of your previous post doesn't make any sense!

And if you are not interested in software development field then this sponsorship is not for you because it requires some programming skills .

And if you have to mail this by tomorrow, how long ago was this assignment given to you?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hey dude i m not perfect in ny of prog lang....so i asked!!

Also i m focusing on network oriented career in future.....so don't knw any kinda lang..

i hav 2 mail dis problem 4 project sponsership...

Plz help!!

Have you attended any programming language lessons? If no then how do you expect to solve this problem.
Are you telling us to give you the solution so you can profit from our work? And then what?...
If this kind of project was asked for the sponsorship, it means that it is required for you to know these things. What will you do after you get the sponsorship? How will you solve future problems?

This problem is very easy. It only requires basic knowledge. Do some studying and read some tutorials.
When was this problem given to you and how much time was given to you to solve this?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Remainder after dividing 278 by 10 = 2

The Remainder is not 2, it is 8. (modulo operation)

278/10 = 27.8

Take the number as a String. Actually it should be treated as a String to begin with:
"458343238143257"
Use the String class to convert that into an array of characters and loop the array.
In the loop take the odd indexed characters. Convert each character to a String (String class API), then that Stirng to an int (Integer class API) and then add them. (Classic for-loop for calculating sums)
Do the same for the even indexed characters.
Then follow the instructions: Multiply(2), add(3), divide(4), subtract(5).
Then concatenate the result to the original String.

Use the API of the classes:
java.lang.String
java.lang.Integer