|
Thanks Vilmos ...for your suggestion...
But that didn't work..
i shall give you the error that i am getting:
"assert should not be used as an identifier since it is reserved keyword from source level 1.4"
For the following lines in my code ,
assert isValidRank(rank);
assert isValidSuit(suit);
i am getting the error: "Syntax error on token "assert",assert excepted"
Actually now iam very much confused as of how to use the assert properly....please help me friends..
|
|
|
|
|
I got the exact same error as you did, but only when I compiled the code with version 1.3 of Java. Are you sure that your compiler is set to Java version 1.4 or higher?
|
|
|
|
|
If you use Java 1.4, you need the compiler option "-source 1.4". assert became a keyword in Java 1.4. Prior to that, assert could be legally used as an identifier. In Java 5 and later, you don't need anything special.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
try this
boolean rankToString(ACE) == "Ace";
boolean rankToString(DEUCE) == "Deuce";
assert rankToString(ACE) == "Ace";
assert rankToString(DEUCE) == "Deuce";
for more information read this page
exactly this paragraph
"Do not use assertions to do any work that your application requires for correct operation.
Because assertions may be disabled, programs must not assume that the boolean expression contained in an assertion will be evaluated. Violating this rule has dire consequences. For example, suppose you wanted to remove all of the null elements from a list names, and knew that the list contained one or more nulls. It would be wrong to do this:
assert names.remove(null);
The program would work fine when asserts were enabled, but would fail when they were disabled, as it would no longer remove the null elements from the list. The correct idiom is to perform the action before the assertion and then assert that the action succeeded:
boolean nullsRemoved = names.remove(null);
assert nullsRemoved;
As a rule, the expressions contained in assertions should be free of side effects: evaluating the expression should not affect any state that is visible after the evaluation is complete. One exception to this rule is that assertions can modify state that is used only from within other assertions. An idiom that makes use of this exception is presented later in this document. "
|
|
|
|
|
I would like to write in java (or other language ) application
which will be count area of a suare, rectangle, circle et cetera.
Dimensions are variable.
http://wgrajfoto.pl/pokaz/img1010/symbolcfc1.jpg
How to create that mathematical symbol ? I would also like to create
; integral , derivative and other mathematical symbol.
The result I am going to save to pdf using Itext.
|
|
|
|
|
Your question is not very clear. Do you want to draw the shapes based on dimensions passed by the user, or just print some formula to the screen?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I would like to print mathematical formulas on the screen like fraction
, integrals, matrix et cetera. I want to write this symbol using some methods
or application.
I don't want to input jpg with mathematical formula.
( Probably For C# there is MathML to create mathematical symbols.
I am looking for counterpart of this application for Java.)
I don't need drawings
I want to create this in java
http://www.speedyshare.com/files/24896488/ram.pd
|
|
|
|
|
I think you may find something to help you here[^] - always the best place to start.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Or you could Google for "java mathml". It pulls up a number of links like JEuclid that supposedly allow you to use MathML with Java.
|
|
|
|
|
How are the Java interface components made visible once created and setVisible(true). Is it running a never ending loop and waiting for events happen. And when event happen it stops the loop?
I mean if its just a procedure the interface should be visible as long as the procedure runs and once its completed the process should exit.
So its a loop? can i create my own Frames, Components with custom features. Couldn't find any loop which waits for input events any where in Swing or awt code
|
|
|
|
|
This is all handled by the Framework in the JVM. The Java application is handed events, messages etc by the JVM as long as it remains active. The application continues to run until it receives a message to close itself or is closed by the Framework.
kanishka_3000 wrote: Couldn't find any loop which waits for input events any where in Swing or awt code
You do not need a loop, you just need handlers for all the events that your program handles. Any events that you do not handle are disposed of by the default handler in the framework. You may find it useful to review some of the tutorials here[^] for further information.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Thanks, what I need is to create a simple component similar to a Frame.
eg
public static void main(String args[]){
MySpecialFrame a =new MySpecialFrame();
a.startTheFrame();
}
so after startTheFrame() the MySpecialFrame component should wait for events just like a Frame. I tried extending from the Container component and calling the setVisible but didn't work. Only extending from Frame works.
|
|
|
|
|
kanishka_3000 wrote: Only extending from Frame works.
That's how it is designed to work. I think you just have to follow the rules of the system in order to create your appp, the same way you would in C++ or C# with Windows.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
hi Everyone,
Actually i want to develop antivirus software in java i have implement to some extend what the problem gernrate at the time of sandboxing can someone help in that if any then i will provide the code mail me at approach2kb@gmail.com
Thanks
in advance
modified on Monday, October 25, 2010 8:03 AM
|
|
|
|
|
Please, see point 2 here[^]
|
|
|
|
|
hi friends...
i am trying to do a simple java program in which i need two methods.....first method to get two values from the user.... 2nd method to find the sum of these two values......and the final main method to print the result....
i don't know why i am not able to get a result for that....can anybody help me to write the correct program,i need the correct code so that i can compare it with my code and find out my mistakes.....
|
|
|
|
|
why dont you give us your code to see, besides havent you heard of getters/setters try that...
we are what we are, but our true self comes with polishing of hardwork
|
|
|
|
|
below given is my code....
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class Sum
{
public void getvalue() throws NumberFormatException, IOException
{
System.out.println("Enter two numbers :");
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
int a=Integer.parseInt(br.readLine());
int b=Integer.parseInt(br.readLine());
}
public int sum(int a,int b)
{
return(a+b);
}
public static void main(String args[]) throws NumberFormatException, IOException
{
Sum obj=new Sum();
obj.getvalue();
int sum=obj.sum(int a,int b);
System.out.println("Sum :"+ sum);
}
}
|
|
|
|
|
There are a few things which are going wrong.
1. int sum=obj.sum(int a,int b); is a big nono (you cannot call a function like this)
2. getvalue ask for two numbers but never actually stores it for use (unless you count the local int a and int b as storing it for further use.
You should store the value a and b on instance level, eg:
class Sum {
protected int a;
protected int b;
public void getvalue() throws NumberFormatException, IOException
{
System.out.println("Enter two numbers :");
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
}
public int sum(int a,int b)
{
return(a+b);
}
static void main(String args[]) {
Sum obj=new Sum();
obj.getvalue();
int sum=obj.sum(obj.a,obj.b);
System.out.println("Sum :"+ sum);
}
}
|
|
|
|
|
Take a look at some of the samples here[^] to understand how to handle variables and pass them into and out of methods.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
hello i am developing a advance java application in which i have to put a web cam image capture feature for client simplicity, i have already used and patched method to browse,store and display image,but how to do it through java code(i mean the code invoke webcam device and capture image) ,please give suggestions ,and if please please provide examples with links and if available the third party api reference.
Thanks and Regards
Alok sharma
|
|
|
|
|
You can't do the camara capture using Servlet or JSP (these things are server side). You will have to do it either in JavaScript or a Java applet or ActiveX component (which wont work in anything other then IE).
For the applet read the following thread on the java forums, which discusses this issue.
|
|
|
|
|
Thanks for reply but JMF is not a free library, besides how to do it through javascript???
|
|
|
|
|
Hello Friends ,
I'm in Final year of computer science .so , i want to developed a project which is based on Real motion of video.
Plz help me ab dat project code.............
I want ready project in which source code in java.]
project title is that.........
" Real-time Motion Trackig and Object Detection in Surveillance Video"
plz send me ready code for this project title...........
ok
bye.......
|
|
|
|
|
Did you read the guidelines above?
Part of # 2 says:
Don't ask "can someone send me the code to create an application that does 'X'.
# 11 says:
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
Given these two points, you are not going to get what you are asking from this forum. Look around and you will see many replies saying the same thing.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|