Science topic

Java Language - Science topic

Explore the latest questions and answers in Java Language, and find Java Language experts.
Questions related to Java Language
  • asked a question related to Java Language
Question
4 answers
Hi guys!
I am currently in my 4th semester (2nd year ending). Due to my negligence I did not plan my future but I would like at least start now. please help me build my resume for the campus interviews.
I am learning python and Java languages at present. And I know the basics of C language . I was suggested to be familiar to Unix operating system. If you have any suggestions for for what to learn or where to join for any experience please let me know.
Relevant answer
Answer
you should first concentrate on your studies first
  • asked a question related to Java Language
Question
1 answer
I'm coding VRP with profit, using ALNS + Simulated Annealing algorithm and Java language. I store tours, customers in ArrayLists.
I read papers and some authors can run VRP with Pickup and Delivery with 1000 customers, 20000 destroy-repair Iteration in few hours.
In my case, after testing with 100-200 customer and 10000 iterations, the running time is reasonable (under 30 minutes).
But when I tries with 600 customers and 10000 iterations, the code runs very slow (3-4 minutes per iteration).
Does my code has problem? I tried with LinkedList but the result is the same.
Please give me some advice about programming this problem.
Relevant answer
Answer
the problem is fixed:
Never use LinkedList: searching takes very long time.
Never use TreeMap to sort large data, it sorts every time you put a data into TreeMap.
Never use stream method + arrow function (Java 8) with large lists. It takes very long time.
  • asked a question related to Java Language
Question
5 answers
We are currently using opencv for face detection and is there any algorithm or library that might help us in facial feature extraction so that we can use it later for emotion classification using fuzzy logic?
Relevant answer
Answer
What is your intention with fuzzy with this?
  • asked a question related to Java Language
Question
15 answers
I want to extract information related to diseases from text. How can I do that using NLP? I prefer to use JAVA language.
Relevant answer
Answer
i guess it late reply, this may help others wrote java library to extract the stopping and stemmer words from given link/file/text i guess that may help you.
source code of library git : https://github.com/uttesh/exude
  • asked a question related to Java Language
Question
10 answers
I am designing a document reccommender system, where i need to use maching learning algorithm for document classification and PHP language do not have libraries available to do this task. as i have to play with user behaviours as well that's why i have designed my application in PHP. Is it possible to use python/java for document classification (using machine learning algorithm such as SVM, Naive byes) and use its results in PHP application?
Relevant answer
Answer
If your application is enterprise, the best way is to use general integration patterns like Web Services or Messaging. This way you can integrate PHP to Java, Python or every other programming language. Also you can decouple the implementations of front-end (PHP) & back-end (Java/Python) in a very clean manner.
There are a lot of Web Service (SOAP/REST) libraries or Messaging libraries for either PHP, Java, Python or other languages. You can find the best option which is proportionate for your application by searching in google.
  • asked a question related to Java Language
Question
3 answers
According to the formula:
Y = Xβ + Zu + e, (1)
where Y is the vector of observed phenotypes; β is an unknown vector containing fixed effects, including the genetic marker, population structure (Q), and the intercept; u is an unknown vector of random additive genetic effects from multiple background QTL for individuals/lines; X and Z are the known design matrices; and e is the unobserved vector of residuals.
In the program, I can add 3 files:
1st is the genotype data
2st is the phenotype data + covariates
3st is the relationship matrix
So, I don´t know how can I add the "sex and hatches" like a fixed effects on the model.
Relevant answer
Answer
A factor can be treated as a covariate Fabio.  
  • asked a question related to Java Language
Question
6 answers
Here are my codes:
if i want to do this addition 11+22 upon clicking on = button it should give me 33 but it does not work. the calculator must be able to perform addition correctly please help?
ActivityMain <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
tools:context=".MainActivity" />
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/editText1"
android:layout_marginTop="36dp"
android:text="1"
android:onClick="btn1Click"/>
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btn1"
android:layout_alignBottom="@+id/btn1"
android:layout_toRightOf="@+id/btn1"
android:text="2"
android:onClick="btn2Click" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btn2"
android:layout_alignBottom="@+id/btn2"
android:layout_toRightOf="@+id/btn2"
android:text="3"
android:onClick="btn3Click"/>
<Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btn1"
android:layout_marginTop="15dp"
android:text="4" />
<Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btn4"
android:layout_alignBottom="@+id/btn4"
android:layout_toRightOf="@+id/btn4"
android:text="5" />
<Button
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btn3"
android:layout_alignParentRight="true"
android:text="+"
android:onClick="btnAddClick"/>
<Button
android:id="@+id/btnSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btn5"
android:layout_alignParentRight="true"
android:text="-"
android:onClick="btnSubClick"/>
<Button
android:id="@+id/btnDiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:text="/" />
<Button
android:id="@+id/btnMul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/btnDiv"
android:layout_marginTop="14dp"
android:text="*" />
<Button
android:id="@+id/btnEqual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/btnMul"
android:layout_marginTop="15dp"
android:text="="
android:onClick="btnEq"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/editText1"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge" />
public class MainActivity extends Activity {
Button btn1;
Button btn2;
Button btn3;
Button btnAdd;
Button btnSub;
String btn_val1;
String btn_val2;
String btn_val3;
String btn_valAdd;
String btn_valSub;
EditText edit_text;
TextView textview;
int res;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void btn1Click(View view)
{
btn1 = (Button) findViewById(R.id.btn1);
btn_val1 = btn1.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview .append(btn_val1);
}
public void btn2Click(View view)
{
btn2 = (Button) findViewById(R.id.btn2);
btn_val2 = btn2.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview .append(btn_val2);
}
public void btn3Click(View view)
{
btn3 = (Button) findViewById(R.id.btn3);
btn_val3 = btn3.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview.append(btn_val3);
}
public void btnAddClick(View view)
{
btnAdd = (Button) findViewById(R.id.btnAdd);
//res = Integer.parseInt(btn_val1) + Integer.parseInt(btn_val2) + Integer.parseInt(btn_val3);
btn_valAdd = btnAdd.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview.append(btn_valAdd);
}
public void btnSubClick(View view)
{
btnSub = (Button) findViewById(R.id.btnSub);
//res = Integer.parseInt(btn_val1) - Integer.parseInt(btn_val2) - Integer.parseInt(btn_val3);
btn_valSub = btnSub.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview.append(btn_valSub);
}
public void btnEq(View view)
{
textview = (TextView) findViewById(R.id.textView2);
if(btnAdd != null)
{
if(btn_val1 != null && btn_val2 != null )
{
res = Integer.parseInt(btn_val1) + Integer.parseInt(btn_val2);
textview.setText(String.valueOf(res));
}
else if(btn_val1 != null && btn_val3 != null)
{
res = Integer.parseInt(btn_val1) + Integer.parseInt(btn_val3);
textview.setText(String.valueOf(res));
}
else if(btn_val2 != null && btn_val3 != null)
{
res = Integer.parseInt(btn_val2) + Integer.parseInt(btn_val3);
textview.setText(String.valueOf(res));
}
else if(btn_val1 != null && btn_val2 != null && btn_val3 != null)
{
res = Integer.parseInt(btn_val1) + Integer.parseInt(btn_val2) + Integer.parseInt(btn_val3);
textview.setText(String.valueOf(res));
}
}
else if(btnSub != null)
{
res = Integer.parseInt(btn_val1) - Integer.parseInt(btn_val2) - Integer.parseInt(btn_val3);
textview.setText(String.valueOf(res));
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Relevant answer
Answer
Dear Nitish,
Here is a complete working code that I have written just for you I hope it helps you, and feel free to contact me if you need more help:
---------------------------------------------------------------------------------------------------
/** Author @Kelechi C Ofoleta*/
package com.kogonuso.calculator;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class Main extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText n1 = (EditText)findViewById(R.id.editText1);
EditText n2 = (EditText)findViewById(R.id.editText2);
TextView msg = (TextView)findViewById(R.id.msg);
try{
if((n1.getText().equals("")) || (n2.getText().equals(""))){
return;
}else{
double a = Double.valueOf(n1.getText().toString()).doubleValue();
double b = Double.parseDouble(n2.getText().toString());
double result = a+b;
msg.setText(result+"");
}
}catch(Exception e){
Toast bread = Toast.makeText(Main.this, "You must enter numbers to continue",Toast.LENGTH_LONG);
}
}
});
}
}
----------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Calculator</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="input1"></string>
<string name="input2"></string>
<string name="Number1">Number 1:</string>
<string name="Number2">Number 2:</string>
<string name="calc">Calc</string>
</resources>
------------------------------------------------------------------------------------------------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.kogonuso.calculator.Main" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Number1" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:text="@string/input1" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Number2" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:text="@string/input2" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/calc" />
<TextView
android:id="@+id/msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
---------------------------------------------------------------------------------
  • asked a question related to Java Language
Question
5 answers
Need a code of some heuristics algorithms like PSO, GA, ACO, DEA as resource allocation at the cloudlet level that allocate cloudlet to different VMS in datacenterbroker. Please I would like to know how I can implement this algorithm in java code if you have any code of these algorithms please send to me to implement a new one like it thanks in advance.
Relevant answer
Answer
Dear Elhossiny,
In order to implement your code, you should write your own classes which are related to your heuristics algorithm and use CloudSim libraries/classes to build up your approach. Suppose you want to implement your algorithm in Java environment. CloudSim only provides the libraries/classes you may need for coding. As an example if you want to implement GA, the following scheme might help you: Create a class and define the structure of a genome/chromosome based on your requirements. Then you should build another class/classes to use genome/chromosome structure for your desired approach and implement all methods you may need such as mutation, crossover, fitness function and etc. These methods use CloudSim classes/libraries to complement your approach.
Regards,
Amirmohammad
  • asked a question related to Java Language
Question
4 answers
Is there any domain ontologies (in owl format) which capture the educational concepts in the JAVA programming course or c++ ?
Relevant answer
Answer
Hi Mona,
Linked Open Vocabularies (LOV) is great initiative when you are looking for existing ontologies that describe certain concept. You could simply search for a certain class or property and get links to the matched ontologies as a result .
The links usually contain descriptions of the classes and properties of an ontology as well as file in OWL, RDF or other Semantic Web/LOD standard format of the ontology that you could easily convert to OWL (if necessary) using online converters for instance.
Hope you'll find this useful,
Bojan
  • asked a question related to Java Language
Question
6 answers
I would like develop app on android to implement dijkstra algorithm using google map.
Relevant answer
Answer
I'm not sure why you would want to do this. Dijstra's algorithm works at the graph level, calculating the cost of  traversing from a start node to every other node in the graph. Within the various APIs available for Google Maps none of them allow this level of access. But the routing APIs allow fast path finding, with options for multiple routes, way points  and modes of travel. If you need to find many routes at once, the DistMatrix API allows you to calculate many routes in one API call to Google.
I've used Graphhopper quite a lot it's a good and stable piece of software. The principle drawback is that it relies on the correctness of Open StreetMap, although for many cities OSM appears to be good enough. If you look at the GraphHopper documentation you will find that an implementation of Dijkstra comes with the distribution (along with A* etc) and that you can access the data structures created at a lower level (but looking at the documentation they are more complex than a simplistic graph of streets and junctions).
Perhaps you could tell us more about the actual problem that you wish to solve, as I suspect that one of the solutions described above will provide you with the functionality that you're expecting from Dijkstra.
One final point....  Dijkstra is an exhaustive search, if you were to set it loose on the street graph of a major city or continent you might be in for a long wait!
  • asked a question related to Java Language
Question
10 answers
Bkd-tree is an extension of kd-tree which is dynamic and scalable. I need a java implementation of Bkd-tree to use in my project which is focused on dynamic data clustering method by multi-agent technology. I tried to find an implementation of Bkd-tree, but was unable to find a reasonable answer. Could someone help me to find a solution for this problem ?
Relevant answer
Answer
Update:
is now ready.
As far as I know it is the only open-source crit-bit tree that supports range queries on keys with multiple dimensions.
  • asked a question related to Java Language
Question
22 answers
Is either netbeans, eclipse or other IDE better?
Relevant answer
Answer
I also agree with Koen, but I will still add my own choice and will not that it is only my preference, not a claim that it is in any way "the best solution" based on some arbitrary evaluation. My choice would be Eclipse because I believe it to be more flexible then NetBeans. There are more plugins and plugins are easier to write. There are a lot of bundles for different platforms (Android, Java for Web, Java ME for embedded solutions, etc.). Eclipse would be my choice of IDE when ever I have the option to chose it for myself for development.