|
Hi Mike,
My problem is how do I make the tmpTutor.getId() and tmpSubject.getId() mehtod static so that I could implement in my controller ?
Cos right now, I can only insert the tutorDAOImpl when I do the preparedStatement for tutor.
When I want to do the associateTutorToSubject, I can't do it the way like yo said cos tutorDAOImpl and SubjectDAOImpl are both separate classes. And so there is no way for the controller to read the getId from the tutorDAOImpl etc.
|
|
|
|
|
when i select jcombobox the database should retrieve in Jtable
|
|
|
|
|
Yes, it should. And if it doesn't it's a very naughty boy.
|
|
|
|
|
|
I try to bring a sense of perspective sometimes.
|
|
|
|
|
Hi! I am learning servlet, can someone kind enough to explain where to place the username, password, address, and port to be used in connection to a MySQL database in WAMP instead of placing it in the code? So that if the address of MySql or server is changed I will not have to change the code. Take the succeding as an example, "jdbc:mysql://localhost:3306/sonoo","root","root"). I am thinking if they are written in the code and they will be changed like the password for mysql will be changed, I will have to change the code. Thus, where will I put the localhost, 3306, sonoo, root, and root so that I will not change the code everytime the address and password, etc. will change. I am using netbeans and apache tomcat. Thank you so much.
|
|
|
|
|
|
How can I change tempo of a jetfile in android?
|
|
|
|
|
|
public class Try_Array
{
public void cool(int[] a)
{
Second_Arra(a);
First_Array(a);
}
private void First_Array(int[] a )
{
for (int i = 0; i < a.length; i++)
a[i] = 10;
}
private void Second_Arra(int[] a )
{
for (int i = 0; i < a.length; i++)
a[i] = 100;
}
}
public class ArrayDemo
{
public static void main(String[] args){
int[] a = {99, 5, 4, };
Try_Array=new Try_Array();
Obj.cool(a);
System.out.println("Array values after sorting:");
for (int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println();
}
}
the Output :
Array values after sorting:
100 100 100
why Java Invoke First_Array(a) not Second_Arra(a); I got confuse !!!!! did java chose random method or what !
|
|
|
|
|
I cannot see how you can get any results, since that code will not even compile.
|
|
|
|
|
it's work fine the output :
Array values after sorting:
10 10 10
so my question how java invoke First_Array(a); not Second_Arra(a) ,
|
|
|
|
|
I copied the code from your question and it definitely does not compile.
|
|
|
|
|
public class ArrayDemo
{
public static void main(String[] args){
int[] a = {99, 5, 4, };
Try_Array Obj =new Try_Array();
Obj.cool(a);
System.out.println("Array values after sorting:");
for (int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println();
}
}
public class Try_Array
{
public void cool(int[] a)
{
Second_Arra(a);
First_Array(a);
}
private void First_Array(int[] a )
{
for (int i = 0; i < a.length; i++)
a[i] = 10;
}
private void Second_Arra(int[] a )
{
for (int i = 0; i < a.length; i++)
a[i] = 100;
}
}
Ok Sorry my Mistake , i fix it now , why and how java invoke First_Array(a); not Second_Arra(a); is that random , I got confuse
|
|
|
|
|
there is nothing random in this, it calls the methods in the order you have coded. So First_Array is called last, and all values are set to 10, there is no sorting done.
|
|
|
|
|
thanks so you saying , java did first calling for Second_Arra(a); then did call First_Array(a);
so Java brought ma final value to the main method .
ok that make sense now .
but still not logic for me how java process the code , for example :
I didn't create instance variable for the class Try_Array.
i don't declare variable like int a[]; and i don't create set() and get() . i don't even do return method !
how for loop (int i = 0; i < a.length; i++) on the main method knows that a[] is got handled with Try_Array class and that array got full with new value !
I just no longer able to trace how java process this I really lost and got crazy to fail understand simple thing
when I build the code I build return method that brought final value I usually build private instance variable for the class . but I got confuse when I saw this code on book not adhere to what I learn
|
|
|
|
|
The code does exactly what you tell it:
- You create the array
a with some values - You create the Obj object
- You call Obj.cool passing in the array
- Obj.cool calls Second_Arra which sets all the values to 100
- Obj.cool next calls First_Array which sets all the values to 10
- You print the contents of the array
|
|
|
|
|
ok thank you so much I would like to clear my point this time how about passing variable
public class ArrayDemo
{
public static void main(String[] args){
int a = 5;
Try_Array Obj =new Try_Array();
Obj.cool(a);
System.out.println("A value After Calling:");
System.out.print(a );
}
}
public class Try_Array
{
public void cool( int a)
{
First_Array(a);
Second_Arra(a);
}
private void First_Array(int a )
{
a=4;
}
private void Second_Arra(int a )
{
a=6;
}
}
the out put is :
A value After Calling:
5
it' should be 6 ; but seam java ignore invocation with variable but java not behave like this with array
do you see my point when I pass array it got effect and back with different but when I send variable back nothing and it will not get effect or change the variable !
|
|
|
|
|
No, it should be 5. Since this is a simple variable, it is passed by value, so each called method gets a copy of the variable a. When they try to change it they only change the copy they have received, not the original variable. You should go to The Java™ Tutorials[^], especially section Passing Information to a Method or a Constructor[^] which explains it in detail.
|
|
|
|
|
Dear Richard your comment help me a lot thank you for guide me to the important topic and basic point that I really miss , you know what I spend 3 month reading with java when I reach recursion it was setback for me I shocked when book give example with mergesort, he build array on Fantasy way that I got really confuse and frustrated that i'm able to follow so I just back for reading previous chapters .
thank you so much I really appreciate your time.
|
|
|
|
|
Hello!
This is my first topic and I will search for other forums as well that might be more into ANN's. As the subjects indicates I have a huge interest in ANN's.
I would like to find people that are intereseted in ANN's and want to code or is coding already in Java and learn more about code implementation, testing and experimenting with ANN's.
I have built my own "library" and implemented it partially. It solves the XOR problem by using LMS algorithm for updating weights and now I am trying to implement the Backpropagation algorithm. Which is a pain in the ass becuase of the way I am storing stuff in my arrays. Meaning that calculating the backpropagation-deltas for the hiddenlayer is a bit of a challenge right now and that is where I am.
I have also creted classes that are objects such as Layer.java, Neuron.java and Weight.java. I will rewrite my code so that I use these classes as Layer[], Neuron[] and Weight[] instead of double[] and int[].
My bachelor topic had to do with topology mutating ANN's that use a simple genetic mutation of the weights to update the network and also the topology; a kind of placticity.
I am up for sharing this on GitHub and further developing it together with someone that also has a huge interest in this stuff! My goal is to reach to the point where a reward-based ANN, combined with this new code structure I am working on and with the code from my bachelor project. For example I would like to try to make ANN's cooperate with other ANN's. So that one ANN acts as visual input while another ANN acts as a generalization network trying to understand and categorize what is "seen".
So is anyone interested in helping and discussing this and coming with ideas and challenges? Or do you have any thoughts about this?
Also if you know any forum that is more suited for ANN then please suggest it! I would be very happy!
|
|
|
|
|
Member 13241109 wrote: I have also creted classes that are objects such as Layer.java, Neuron.java and Weight.java. I will rewrite my code so that I use these classes as Layer[], Neuron[] and Weight[] instead of double[] and int[]. Why weights and neurons? This just adds a whole bunch of pointless overhead, and no significant encapsulation. The only thing worth encapsulating is a whole layer, and only because you can have different types of layer (standard, conv, pooling, etc).
|
|
|
|
|
Yes true you are right I don't really have any use of those objects right now. The code works and would work without these object classes. Hopefully they will prove to be useful when say I would want to implement plasticity or list all inputs and outputs from neuron X in the hidden layer Y. I don't know if there is a better way. Also I hope it will make the code easier to read and give me more control over what goes where. This also forces the objects to be of the type double[] or I can create additional methods that only apply to the objects of type Weights or Neuron and it would structure the code better. I'll see how it plays out.
|
|
|
|
|
Hi experts,
I hope someone can tell me how to write the code which I have stumbled :
<pre>subject m = new subject();
List<subject>subject = new ArrayList<subject>();
String[] subjects = subject.toArray(new String[subject.size()]);
subjects = request.getParameterValues("subject");
for (int i = 0; i< subjects.length; i++){
if (subjects != null) {
m.setSubjects(subject);
mgr.insertSubject(m);
Basically, I do not know how do I add the subjects into generic List<subject>subject.
Hope someone can guide me here.
Tks.
|
|
|
|
|
There are several confusions in your code, you are creating List, then going back to static arrays, then... Wait right,
What you need to do is, you need to add subjects, then convert it to array, I would suggest performing the conversion from List to array at the end. What happens is that your list is employ, and thus your array is also of zero size, so you cannot add anything and if you do add something to list (later on, after creating the array), you do not get that in the array.
Besides, Java doesn't allow same name to be reused for multiple types (your class type, variable name, etc.) so please review the code, and if someone gave it to you, lure them with you to the Java tutorials or classes.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|