|
Hi Richard MacCutchan,
Before I posted my question here, I had googled for this subject but I did not find what I need so I hope to receive sharing of experiences from you about this.
|
|
|
|
|
Did you look at the link that I posted? There are lots of hits from my Google search, I don't know what keywords you used.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Yes, of course.
I want to use an open source (free) for my app and I don't know what is suitable with my need.
|
|
|
|
|
pcphuc wrote: I want to use an open source (free) for my app and I don't know what is suitable with my need.
You need to research the products that are available and select the one that you think fulfils your need.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Thanks for your help.
I think I'll try JACOB/J-XChange.
Have a nice day
|
|
|
|
|
hi friends...
i was trying to do a sample program got from java tutorials ,where i encountered some errors with the use of assert keyword....can anyone help me to solve the problem..i am doing the program in eclipse...
Below given is my code...
public class Card {
private final int rank;
private final int suit;
public final static int DIAMONDS = 1;
public final static int CLUBS = 2;
public final static int ACE = 1;
public final static int DEUCE = 2;
public Card(int rank, int suit) {
assert isValidRank(rank);
assert isValidSuit(suit);
this.rank = rank;
this.suit = suit;
}
public int getSuit() {
return suit;
}
public int getRank() {
return rank;
}
public static boolean isValidRank(int rank) {
return ACE <= rank && rank <= KING;
}
public static boolean isValidSuit(int suit) {
return DIAMONDS <= suit && suit <= SPADES;
}
public static String rankToString(int rank) {
switch (rank) {
case ACE:
return "Ace";
case DEUCE:
return "Deuce";
default:
return null;
}
}
public static String suitToString(int suit) {
switch (suit) {
case DIAMONDS:
return "Diamonds";
case CLUBS:
return "Clubs";
default:
return null;
}
}
public static void main(String[] args) {
assert rankToString(ACE) == "Ace";
assert rankToString(DEUCE) == "Deuce";
}
}
|
|
|
|
|
When you are comparing strings in java, always use the equals(object) methid:
assert rankToString(ACE).equals("Ace");
assert rankToString(DEUCE).equals("Deuce");
As an aside, when there are a finite set of values - as in card ranks and suits - use an enum and all this checking for valid values goes away.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
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);
}
}
|
|
|
|