|
|
I doubt that anyone here is going to provide such a tutorial. Go back to the Jasa site and use the links under Contacts and Support.
|
|
|
|
|
Hello,
Please have a look at readme.md[^] file available with JASA source code.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
suppose string is "mam is going"..so now finding each character occurances.....
|
|
|
|
|
Here is the function where your get the occurrence of each character in any string with O(n) times.
public static void main(String args[]){
String str="mam is going";
HashMap<String, Integer> freqOfChar=calculateCharFrequency(str!=null?str.trim():"");
printFreeOfChar(freqOfChar);
}
static HashMap<String, Integer> calculateCharFrequency(String str){
HashMap<String, Integer> freqOfChar = new HashMap<String, Integer>();
String ch;
if(str!=null){
for(int i=0;i<str.length();i++){
ch=Character.toString(str.charAt(i)).trim();
if(ch.length()>0){
if(freqOfChar.get(ch)!=null){
freqOfChar.put(ch, (freqOfChar.get(ch)+1));
}else{
freqOfChar.put(ch, 1);
}
}
}
}
return freqOfChar;
}
static void printFreeOfChar(HashMap<String, Integer> freqOfChar){
for (String key : freqOfChar.keySet()) {
System.out.println("Char: "+key+ "; Occurance: "+freqOfChar.get(key));
}
}
output:
Char: o; Occurance: 1
Char: i; Occurance: 2
Char: m; Occurance: 2
Char: a; Occurance: 1
Char: n; Occurance: 1
Char: g; Occurance: 2
Char: s; Occurance: 1
|
|
|
|
|
Why do you do his homework?
Does he pay you?
Does he learn anything?
regards Torsten
I never finish anyth...
|
|
|
|
|
Please let me now how can I set value and text to compbobox
so that I can attach empid and empname both to single combobox, where I want display to empname and on selection I want to fetch other details of emp on empid where empid is FKEY in details datatable.
It is possible in VB by setting value and text, how it possible Java pls anybody have idea pls help me
|
|
|
|
|
|
Sorry Dear,
As per my knowledge there is no method exists JComboBox as setLable or setValue, could you please write a small code for me and help.
|
|
|
|
|
|
Both final class and a class with a private constructor cannot be inherited, so what is the difference?
Also both abstract class and a class with a private constructor cannot be instantiated, again what is the difference then?
|
|
|
|
|
Google for these class types and you will find full explanations.
|
|
|
|
|
I tried, but i am unable to understand. Please mail me the description. I mean i understand these classes but am not able to pinpoint the precise difference. Like in private constructor class object can be created using some static method but it is not possible in a abstract class. Likewise for the other case. So please provide me ur expertise. I am desperate for the answer.
|
|
|
|
|
I don't have anything to mail to you. This information is all available in any of the many Java study guides and online tutorials, which is all that I could offer to provide for you. I'm sorry if you find it difficult to understand but it is most unlikely that I could provide a better explanation than the many professional authors that write on the subject.
|
|
|
|
|
http://docs.oracle.com/javase/tutorial/index.html[^]
http://docs.oracle.com/javase/tutorial/java/javaOO/index.html[^]
Bookmark that page, it's the one source everyone should know.
The keyword "final" describes, that something is not to be changed. So one can define code that would not be changed. Good example are member variables for Screen solution or basic height/length values or also dialog titles.
A private constructor can not be seen from outside the class. It's private as the word private describes
Sometimes one wants to prohibit the use of the 0-args-constructor, which is there even if it's not explicit defined. That would be a classic use for a private constructor, where I make that one unseen by defining it "private".
An abstract class is an abstract description of something, has basic definition, but does not make the complete scope. Example: Animal. Could be anything and none. Can not be used as itself, needs to be extended to make it something.
regards Torsten
I never finish anyth...
|
|
|
|
|
Hi guys i get code named Txmodem,that sends sms and i'd like to add that code to a previous code made by someone else, using a MVC model,and makes it work like actionlistener, so that the USER just press button to send...but IT GENERATE ERROR when i add this field on previous code..(Note:it works cause i received sms on my phone)
package opti;
import java.io.*;
import java.util.*;
import javax.comm.*;
public class Txmodem implements SerialPortEventListener,
CommPortOwnershipListener {
static String comPort = "COM1";
private CommPortIdentifier portId = null;
private Enumeration portList;
private InputStream inputStream = null;
private OutputStream outputStream = null;
private SerialPort serialPort;
public Txmodem(String comm) {
this.comPort = comm;
}
public boolean init() {
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(comPort)) {
return true;
}
}
}
return false;
}
public void send(String cmd) {
try {
outputStream.write(cmd.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
public void sendMessage(String phoneNumber, String message) {
send("AT+CMGS=\"" + phoneNumber + "\"\r\n");
send(message);
send("\032");
}
public void connect() throws NullPointerException {
if (portId != null) {
try {
portId.addPortOwnershipListener(this);
serialPort = (SerialPort) portId.open("Txmodem", 2000);
} catch (PortInUseException e) {
e.printStackTrace();
}
try {
inputStream = serialPort.getInputStream();
outputStream = serialPort.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
serialPort.addEventListener(this);
serialPort.notifyOnDataAvailable(true);
} catch (TooManyListenersException e) {
e.printStackTrace();
}
} else {
throw new NullPointerException("COM Port non trouvé!!");
}
}
public void serialEvent(javax.comm.SerialPortEvent serialPortEvent) {
switch (serialPortEvent.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[2048];
try {
while (inputStream.available() >
0)
{
int numBytes = inputStream.read(readBuffer);
}
System.out.print(new String(readBuffer));
} catch (IOException e) {
}
break;
}
}
public void ownershipChange(int type) {
switch (type) {
case CommPortOwnershipListener.PORT_UNOWNED:
System.out.println(portId.getName() + ": PORT_UNOWNED");
break;
case CommPortOwnershipListener.PORT_OWNED:
System.out.println(portId.getName() + ": PORT_OWNED");
break;
case CommPortOwnershipListener.PORT_OWNERSHIP_REQUESTED:
System.out.println(portId.getName() + ": PORT_INUSED");
break;
}
}
public static void main(String args[]) {
Txmodem gsm = new Txmodem(comPort);
if (gsm.init()) {
try {
gsm.connect();
Thread.sleep(5000);
gsm.sendMessage("PHONENUMBER", "HERETEHMESSAGE");
Thread.sleep(20000);
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.out.println("ne peut initialiser la carte");
}
}
}
|
|
|
|
|
What error, where does it occur? Please do not expect people to guess what happens in your code.
|
|
|
|
|
Why the doGet() and doPost() methods hava protected modifier
|
|
|
|
|
|
Hi guys, Please tell me is it possible to link java with C# if so then pls tell me how to link C# code to java. Its very urgent for me pls reply as soon as possible. We are working on netbeans so pls let me know how to combine java and C# in netbeans to execute the code.
Thanks in advance.
|
|
|
|
|
You can't; at least, not easily - see How to wrap a C# library for use in Java[^]. Java runs in the Java Virtual Machine under Windows, and C# runs in the .NET framework, which are two distinct and separate environments.
|
|
|
|
|
k is there any tool to convert entire C# code to java code.
|
|
|
|
|
Search Google for "Convert C# to Java". I got this. CS2J[^]
|
|
|
|
|
hi,
try JavaOnet.
i tried it, is working fine, but you need license to use it.
|
|
|
|
|
am using spring MVC and jsp for developing the application. I have a scenario in which I can create or delete a record. index.jsp is the main page where users can see all the records, from there we can create or delete the record, once created or deleted the controller comes back to the same index.jsp with latest changes being shown on the page. Issue is its working fine in FF and chrome but in IE, if I want to see the latest added record or remove the deleted record from the list, I have to close the browser manually and reopen it. I have tried all possible response.setHeaders..to remove the cache in IE. The other approach I tried is to redirect the spring controller, but still IE is not refreshing and not showing the latest changes in index page. Code is as below:
<pre lang="java">@RequestMapping(value = "/createRequest", method = RequestMethod.GET)
public ModelAndView createRequest(final HttpServletRequest request,
final HttpServletResponse response,..)
//logic to create or delete record..
return new ModelAndView("redirect:myredirectPage.htm");
}
@RequestMapping(value="/myredirectPage", method=RequestMethod.GET)
public ModelAndView showMyRedirectPage(){
ModelAndView modelView = new ModelAndView("index");
return modelView;
}
I have added no cache tags in index.jsp as well as create.jsp where we will create the record. Below is the code i kept in jsp: index.jsp:
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
..
</html>
create.jsp:
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
%>
<!DOCTYPE HTML>
<head>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<%@page isELIgnored="false" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@page import="java.util.Date" %>
...
Thanks.
|
|
|
|