|
I have edited. please see where i am doing wrong?
|
|
|
|
|
In the following lines you have calls to getAddress() ...
System.out.println("Customer Address : " +this.getAddress());
System.out.println("New Customer Address :"+ " "+this.getAddress() );
... But that call returns the Customer.Address object which contains various properties. So when you pass that to the println method the system tries to print it. But since it has no idea how to print an Address object it just prints the class name and its memory address. You need to add a toString method to your Address class that returns the address formatted as a string.
|
|
|
|
|
so, we cannot print by just passing values to object of Address class. we must have to use setter method in Address class or toString method. right?
|
|
|
|
|
You should always add a toString method to your classes. All classes are ultimately based on the Object class, which has a very simple toString method (as you have seen). So unless you provide a custom version that is what you will get for your own classes. Remember, the Java system cannot guess what properties, or in what format, you want your classes to be printed.
|
|
|
|
|
got it. thanx
|
|
|
|
|
public void displayCustomerDetails(Address address) {
System.out.println("Displaying customer details \n***************************");
System.out.println("Customer Obj: " + this);
System.out.println("Customer Id : " + customerId);
If you add the line above you will see something like:
Customer@4645
Another approach would be to add a printDetails() method to the Address class and then you could call
… getAddress().printDetails() …
|
|
|
|
|
Solve this question using java programming
Food Festival at HillTown
HillTown Inn is planning to organize a Food Festival bringing together at one place, a wide variety of cuisines from across the world on account of Christmas. The Hotel Management has rented out a square hall of an indoor Auditorium for this extravaganza. The side of the square hall is y inches in which a large square table is placed for the display of the most popular and celebrated food items. The side of the square table is x inches, such that x
|
|
|
|
|
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
And if you're going to post the homework assignment at least post ALL of it. Some of us have completion issues.
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
|
|
|
|
|
i want to learn java, can anyone suggest me
https://myfiosgateway.one/ https://tutuappvip.co/mobdro-download
modified 6-Jun-22 5:33am.
|
|
|
|
|
A course is best - if you don't understand something, then a human can rephrase and try explaining a different way. Do the homework yourself as you learn best by doing, not copy'n'pasting!
The next best is a book: they deal with the material in a structured way, introducing all the language and framework elements in a way so they build on each other. Do all the tests and exercises as you go along - that helps to reinforce what you are learning. Wrox, Addison Wesley, and Microsoft Press all do good ones.
From here on down, it's generally poor: grabbing a compiler and trying things is a really bad way to learn anything useful, but is much better than watching YouTube tutorials - most of which are created by people who don't know how to make a video, don't know how to teach, and more often than not can't code either. Remember that "Likes" and "Subscribes" are currency: they make money so you get a lot of real crap there. There are good ones I'm sure, but they are so swamped under a massive pile of money-making rubbish that they are pretty much impossible to find.
Good luck - but don't expect to become an expert overnight - there is no short cut here!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I am doing an assignment for college and have been stuck on a problem for the last 2 days... all articles and forums have led me down a road of despair. I created a javabean and jsp, but when I run it on Tomcat, I get an error that the class cannot be found. What should be so simple is such a pain in my ___. For the love of God please someone help me haha!
*** I am running on TomCat v10 / Eclipse and have also tried just placing the files inside the TomCat dir; .jsp in ROOT and .java in WEB-INF/classes/ ***
>>> ImpDateBean.jsp <<<
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="javabean.CurrentDate"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>JavaBean Training</title>
</head>
<body>
<jsp:useBean id="Date" class="javabean.CurrentDate" scope="session">
<jsp:setProperty name="Date" property="*" />
</jsp:useBean>
<p>
Today's date is: <br>
<jsp:getProperty name="Date" property="date_today" />
</p>
</body>
</html>
>>> CurrentDate.java <<<
package javabean;
import java.io.Serializable;
import java.util.Date;
public class CurrentDate implements Serializable {
private Date date_today = new Date();
private static final long serialVersionUID = 1L;
public CurrentDate() {}
public CurrentDate(Date date_today) {
this.date_today = date_today;
}
public Date getDay() {
return date_today;
}
public void setDay(Date date_today) {
this.date_today = date_today;
}
}
Thank you!
-Josh
|
|
|
|
|
Type Exception Report
Message /ImpDateBean.jsp (line: [11], column: [2]) The value for the useBean class attribute [javabean.CurrentDate] is invalid.
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: /ImpDateBean.jsp (line: [11], column: [2]) The value for the useBean class attribute [javabean.CurrentDate] is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:292)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:115)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1373)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1189)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2387)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2439)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2445)
org.apache.jasper.compiler.Node$Root.accept(Node.java:473)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2387)
org.apache.jasper.compiler.Generator.generate(Generator.java:3609)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:257)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:391)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:367)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:399)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:380)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:328)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:777)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
|
|
|
|
It is a long time since I worked with JSP, but I recall the bean classes had to be stored in the correct location of the web folders. Where is your class file stored in the server? Please show the complete structure.
|
|
|
|
|
You put .class files in the classes folder.
javac your Java file?
Make sure you keep the .class file in its javabean package folder.
../classes/javabean/CurrentDate.class
|
|
|
|
|
Josh Hebert wrote: package javabean;
import java.io.Serializable;
import java.util.Date;
public class CurrentDate implements Serializable {
Can't say what the root directory should be but you must have the following path under that root.
.\javabean\CurrentDate.class
|
|
|
|
|
Dear Team, I have a background in VB6 and VB.Net. I plan to learn java as additional programming language. I would like to know if I already have experience with VB.Net and plan to switch to Java, is it hard or easy to learn this new programming language?
Thank,
Kanel
|
|
|
|
|
Kanel Roath wrote: is it hard or easy to learn this new programming language? Definitely one or the other. But the only person qualified to answer that question is you. Java, like all programming languages, is hard for some and easy for others, and you cannot really tell how hard you will find it until you start learning. One of the best resources available is Oracle's Java Tutorials Learning Paths[^], so take a look and see for yourself.
|
|
|
|
|
Thank for your respond. I just hope that I could learn some experience from any people that learn Java which is used to have VB.Net as a background.
|
|
|
|
|
Well good luck. But you will find the answer much faster by doing what I suggested and looking at the tutorials.
|
|
|
|
|
That question is impossible for anyone other than YOU to answer.
All I can say is the more languages you learn, the more you discover the concepts behind them are all the same. It's the syntax that changes.
|
|
|
|
|
I also feel that the concept is the same too. But I would like to learn about an experience of people whose used to get start with Java which have VB.net from the background. Thank for your answer.
|
|
|
|
|
Why would you even care about someone else's experience when they are NOT YOU?
Sure, you'll find some people that have made that transition, and they could tell you that it was hard or easy, but then what?
They are not you. They don't have your background experience, nor your level of knowledge, nor your thought process when writing code. Their experience is going to be completely useless in answering your question.
The ONLY way to find the answer to your question is if YOU dive in and find out yourself.
|
|
|
|
|
Difference Between VB.NET and Java - Javatpoint
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I followed your link, and found:
Applications built with Java are very secure, robust, fast performing and platform independent. Due to the reusability of the code, programmers do not need to write Java code at every time, instead they can inherit functionality from the base class or we can say that it follows (WORA) Write once read anywhere which means write the code one time and read or call it anywhere in the programming language. So, in this way it reduces the code complexity in programming. Further, it is platform independent which means the developer does not need to create separate applications for different platforms.
Yeah. I am not going to argue against it. This praise of Java may be appropriate to enlighten "Differences between VB.NET and Java" (the page headline). Yet, it does affect how I read and interpret other pages on that web site.
|
|
|
|